Skip to content

Commit

Permalink
Don't allow double Channel#Open from clients (#614)
Browse files Browse the repository at this point in the history
Fixes #604
  • Loading branch information
carlhoerberg authored Dec 14, 2023
1 parent e1909f4 commit 9ebffb5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lavinmq/client/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,13 @@ module LavinMQ
end

private def open_channel(frame)
@channels[frame.channel] = Client::Channel.new(self, frame.channel)
@vhost.event_tick(EventType::ChannelCreated)
send AMQP::Frame::Channel::OpenOk.new(frame.channel)
if @channels.has_key? frame.channel
close_connection(frame, 504_u16, "CHANNEL_ERROR - second 'channel.open' seen")
else
@channels[frame.channel] = Client::Channel.new(self, frame.channel)
@vhost.event_tick(EventType::ChannelCreated)
send AMQP::Frame::Channel::OpenOk.new(frame.channel)
end
end

# ameba:disable Metrics/CyclomaticComplexity
Expand Down

0 comments on commit 9ebffb5

Please sign in to comment.