Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
merge stable into default
Browse files Browse the repository at this point in the history
  • Loading branch information
rade committed Apr 12, 2013
2 parents 03950a0 + 7264034 commit afcd2c2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/amqp_network_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
-define(RABBIT_TCP_OPTS, [binary, {packet, 0}, {active,false}, {nodelay, true}]).
-define(SOCKET_CLOSING_TIMEOUT, 1000).
-define(HANDSHAKE_RECEIVE_TIMEOUT, 60000).
-define(TCP_MAX_PACKET_SIZE, (16#4000000 + ?EMPTY_FRAME_SIZE - 1)).

-record(state, {sock,
heartbeat,
Expand Down Expand Up @@ -214,12 +215,21 @@ tune(#'connection.tune'{channel_max = ServerChannelMax,
lists:max([Client, Server]);
(Client, Server) ->
lists:min([Client, Server])
end, [ClientChannelMax, ClientHeartbeat, ClientFrameMax],
[ServerChannelMax, ServerHeartbeat, ServerFrameMax]),
NewState = State#state{heartbeat = Heartbeat, frame_max = FrameMax},
end,
[ClientChannelMax, ClientHeartbeat, ClientFrameMax],
[ServerChannelMax, ServerHeartbeat, ServerFrameMax]),
%% If we attempt to recv > 64Mb, inet_drv will return enomem, so
%% we cap the max negotiated frame size accordingly. Note that
%% since we receive the frame header separately, we can actually
%% cope with frame sizes of 64M + ?EMPTY_FRAME_SIZE - 1.
CappedFrameMax = case FrameMax of
0 -> ?TCP_MAX_PACKET_SIZE;
_ -> lists:min([FrameMax, ?TCP_MAX_PACKET_SIZE])
end,
NewState = State#state{heartbeat = Heartbeat, frame_max = CappedFrameMax},
start_heartbeat(SHF, NewState),
{#'connection.tune_ok'{channel_max = ChannelMax,
frame_max = FrameMax,
frame_max = CappedFrameMax,
heartbeat = Heartbeat}, ChannelMax, NewState}.

start_heartbeat(SHF, #state{sock = Sock, heartbeat = Heartbeat}) ->
Expand Down

0 comments on commit afcd2c2

Please sign in to comment.