Skip to content

Commit 9fed71e

Browse files
authored
Merge pull request #40 from JuliaComputing/tan/misc
fix channelmax and framemax negotiations
2 parents 9cf4f68 + a14c259 commit 9fed71e

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/protocol.jl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function connection_processor(c, name, fn)
354354
end
355355

356356
function connection_sender(c::Connection)
357-
@debug("==> sending on conn", host=c.virtualhost)
357+
@debug("==> sending on conn", host=c.host, port=c.port, virtualhost=c.virtualhost)
358358
nbytes = sendq_to_stream(sock(c), c.sendq)
359359
@debug("==> sent", nbytes)
360360
c.heartbeat_time_client = time() # update heartbeat time for client
@@ -1084,6 +1084,7 @@ function on_connection_tune(chan::MessageChannel, m::TAMQPMethodFrame, ctx)
10841084
conn.channelmax = m.payload.fields[1].second
10851085
conn.framemax = m.payload.fields[2].second
10861086
conn.heartbeat = m.payload.fields[3].second
1087+
@debug("got_connection_tune", channelmax=conn.channelmax, framemax=conn.framemax, heartbeat=conn.heartbeat)
10871088
handle(chan, FrameHeartbeat, on_connection_heartbeat)
10881089
send_connection_tune_ok(chan, ctx[:channelmax], ctx[:framemax], ctx[:heartbeat])
10891090
handle(chan, :Connection, :Tune)
@@ -1095,17 +1096,19 @@ end
10951096
function send_connection_tune_ok(chan::MessageChannel, channelmax=0, framemax=0, heartbeat=0)
10961097
conn = chan.conn
10971098

1098-
# set channelmax and framemax
1099-
(channelmax > 0) && (conn.channelmax = channelmax)
1100-
(framemax > 0) && (conn.framemax = framemax)
1101-
1102-
# negotiate heartbeat (min of what expected by both parties)
1103-
if heartbeat > 0 && conn.heartbeat > 0
1104-
conn.heartbeat = min(conn.heartbeat, heartbeat)
1105-
else
1106-
conn.heartbeat = max(conn.heartbeat, heartbeat)
1099+
# negotiate (min of what expected by both parties)
1100+
function opt(desired_param, limited_param)
1101+
if desired_param > 0 && limited_param > 0
1102+
min(desired_param, limited_param)
1103+
else
1104+
max(desired_param, limited_param)
1105+
end
11071106
end
11081107

1108+
conn.channelmax = opt(channelmax, conn.channelmax)
1109+
conn.framemax = opt(framemax, conn.framemax)
1110+
conn.heartbeat = opt(heartbeat, conn.heartbeat)
1111+
11091112
@debug("send_connection_tune_ok", channelmax=conn.channelmax, framemax=conn.framemax, heartbeat=conn.heartbeat)
11101113
send(chan, TAMQPMethodPayload(:Connection, :TuneOk, (conn.channelmax, conn.framemax, conn.heartbeat)))
11111114

test/runtests.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ AMQPTestRPC.runtests()
1010

1111
if length(ARGS) > 0
1212
amqps_host = ARGS[1]
13-
AMQPTestCoverage.runtests(; host=amqps_host, port=AMQPClient.AMQPS_DEFAULT_PORT, amqps=amqps_configure())
13+
virtualhost = ARGS[2]
14+
port = AMQPClient.AMQPS_DEFAULT_PORT
15+
16+
login = ENV["AMQPPLAIN_LOGIN"]
17+
password = ENV["AMQPPLAIN_PASSWORD"]
18+
auth_params = Dict{String,Any}("MECHANISM"=>"AMQPLAIN", "LOGIN"=>login, "PASSWORD"=>password)
19+
20+
AMQPTestCoverage.runtests(; host=amqps_host, port=AMQPClient.AMQPS_DEFAULT_PORT, virtualhost=virtualhost, amqps=amqps_configure(), auth_params=auth_params)
1421
AMQPTestThroughput.runtests(; host=amqps_host, port=AMQPClient.AMQPS_DEFAULT_PORT, tls=true)
1522
AMQPTestRPC.runtests(; host=amqps_host, port=AMQPClient.AMQPS_DEFAULT_PORT, amqps=amqps_configure())
1623
end

0 commit comments

Comments
 (0)