Skip to content

Commit 9c31483

Browse files
authored
Dont call send while holding the channels lock (#200)
1 parent 2823a9e commit 9c31483

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/amqproxy/upstream.cr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ module AMQProxy
3939
end
4040

4141
def open_channel_for(downstream_channel : DownstreamChannel) : UpstreamChannel
42+
upstream_channel = create_upstream_channel(downstream_channel)
43+
send AMQ::Protocol::Frame::Channel::Open.new(upstream_channel.channel)
44+
upstream_channel
45+
end
46+
47+
private def create_upstream_channel(downstream_channel : DownstreamChannel)
4248
@channels_lock.synchronize do
4349
1_u16.upto(@channel_max) do |i|
4450
unless @channels.has_key?(i)
4551
@channels[i] = downstream_channel
46-
send AMQ::Protocol::Frame::Channel::Open.new(i)
4752
return UpstreamChannel.new(self, i)
4853
end
4954
end

0 commit comments

Comments
 (0)