diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-10-29 13:15:19 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-10-29 13:15:19 +0000 |
commit | ad6efb5f26499f4c5c5cc771124382e59791923c (patch) | |
tree | 077108e1af6f18295571e4da0f48a1b76bdd9e61 | |
parent | 6cbcd690d6002557a34e679a6602bb1166d85bcd (diff) | |
parent | 4ac78175b69a77eff0446ba372f969a31708261b (diff) | |
download | rabbitmq-server-ad6efb5f26499f4c5c5cc771124382e59791923c.tar.gz |
Merge bug25254
-rw-r--r-- | src/rabbit_reader.erl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index f4e6865b..e9c18312 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -491,6 +491,14 @@ handle_exception(State, Channel, Reason) -> timer:sleep(?SILENT_CLOSE_DELAY * 1000), throw({handshake_error, State#v1.connection_state, Channel, Reason}). +%% we've "lost sync" with the client and hence must not accept any +%% more input +fatal_frame_error(Error, Type, Channel, Payload, State) -> + frame_error(Error, Type, Channel, Payload, State), + %% grace period to allow transmission of error + timer:sleep(?SILENT_CLOSE_DELAY * 1000), + throw(fatal_frame_error). + frame_error(Error, Type, Channel, Payload, State) -> {Str, Bin} = payload_snippet(Payload), handle_exception(State, Channel, @@ -621,8 +629,9 @@ handle_input(frame_header, <<Type:8,Channel:16,PayloadSize:32>>, State = #v1{connection = #connection{frame_max = FrameMax}}) when FrameMax /= 0 andalso PayloadSize > FrameMax - ?EMPTY_FRAME_SIZE + ?FRAME_SIZE_FUDGE -> - frame_error({frame_too_large, PayloadSize, FrameMax - ?EMPTY_FRAME_SIZE}, - Type, Channel, <<>>, State); + fatal_frame_error( + {frame_too_large, PayloadSize, FrameMax - ?EMPTY_FRAME_SIZE}, + Type, Channel, <<>>, State); handle_input(frame_header, <<Type:8,Channel:16,PayloadSize:32>>, State) -> ensure_stats_timer( switch_callback(State, {frame_payload, Type, Channel, PayloadSize}, @@ -633,8 +642,8 @@ handle_input({frame_payload, Type, Channel, PayloadSize}, Data, State) -> case EndMarker of ?FRAME_END -> State1 = handle_frame(Type, Channel, Payload, State), switch_callback(State1, frame_header, 7); - _ -> frame_error({invalid_frame_end_marker, EndMarker}, - Type, Channel, Payload, State) + _ -> fatal_frame_error({invalid_frame_end_marker, EndMarker}, + Type, Channel, Payload, State) end; %% The two rules pertaining to version negotiation: |