@@ -354,7 +354,7 @@ function connection_processor(c, name, fn)
354
354
end
355
355
356
356
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)
358
358
nbytes = sendq_to_stream (sock (c), c. sendq)
359
359
@debug (" ==> sent" , nbytes)
360
360
c. heartbeat_time_client = time () # update heartbeat time for client
@@ -1084,6 +1084,7 @@ function on_connection_tune(chan::MessageChannel, m::TAMQPMethodFrame, ctx)
1084
1084
conn. channelmax = m. payload. fields[1 ]. second
1085
1085
conn. framemax = m. payload. fields[2 ]. second
1086
1086
conn. heartbeat = m. payload. fields[3 ]. second
1087
+ @debug (" got_connection_tune" , channelmax= conn. channelmax, framemax= conn. framemax, heartbeat= conn. heartbeat)
1087
1088
handle (chan, FrameHeartbeat, on_connection_heartbeat)
1088
1089
send_connection_tune_ok (chan, ctx[:channelmax ], ctx[:framemax ], ctx[:heartbeat ])
1089
1090
handle (chan, :Connection , :Tune )
@@ -1095,17 +1096,19 @@ end
1095
1096
function send_connection_tune_ok (chan:: MessageChannel , channelmax= 0 , framemax= 0 , heartbeat= 0 )
1096
1097
conn = chan. conn
1097
1098
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
1107
1106
end
1108
1107
1108
+ conn. channelmax = opt (channelmax, conn. channelmax)
1109
+ conn. framemax = opt (framemax, conn. framemax)
1110
+ conn. heartbeat = opt (heartbeat, conn. heartbeat)
1111
+
1109
1112
@debug (" send_connection_tune_ok" , channelmax= conn. channelmax, framemax= conn. framemax, heartbeat= conn. heartbeat)
1110
1113
send (chan, TAMQPMethodPayload (:Connection , :TuneOk , (conn. channelmax, conn. framemax, conn. heartbeat)))
1111
1114
0 commit comments