summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-02-10 17:06:42 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2011-02-10 17:06:42 +0000
commit4a31066692b2254b310c4befb461363f0fb6c686 (patch)
tree24df9e04f0dcfe7771e775cbdbacc16acd602de5
parentc6725f21f584b3e51dabb8cc8fa213d5e07ad261 (diff)
downloadrabbitmq-server-4a31066692b2254b310c4befb461363f0fb6c686.tar.gz
Always log the error from the channel; can now guarantee exceptions that turn up in the reader are hard exceptions
-rw-r--r--src/rabbit_channel.erl4
-rw-r--r--src/rabbit_reader.erl23
2 files changed, 9 insertions, 18 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 1598ac4d..b830a2cb 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -362,13 +362,13 @@ send_exception(Reason, State = #ch{channel = Channel,
reader_pid = ReaderPid}) ->
{_ShouldClose, CloseChannel, CloseMethod} =
rabbit_binary_generator:map_exception(Channel, Reason, Protocol),
+ rabbit_log:error("connection ~p, channel ~p - error:~n~p~n",
+ [ReaderPid, Channel, Reason]),
%% something bad's happened: rollback_and_notify make not be 'ok'
rollback_and_notify(State),
State1 = State#ch{state = closing},
case CloseChannel of
Channel ->
- rabbit_log:error("connection ~p, channel ~p - error:~n~p~n",
- [ReaderPid, Channel, Reason]),
ok = rabbit_writer:send_command(WriterPid, CloseMethod),
{noreply, State1};
_ ->
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 0cb4b5bf..951cf439 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -976,29 +976,20 @@ process_channel_frame(Frame, ErrPid, Channel, ChPid, AState) ->
AState
end.
-log_channel_error(ConnectionState, Channel, Reason) ->
- rabbit_log:error("connection ~p (~p), channel ~p - error:~n~p~n",
- [self(), ConnectionState, Channel, Reason]).
-
-handle_exception(State = #v1{connection_state = closed}, Channel, Reason) ->
- log_channel_error(closed, Channel, Reason),
+handle_exception(State = #v1{connection_state = closed}, _Channel, _Reason) ->
State;
-handle_exception(State = #v1{connection_state = CS}, Channel, Reason) ->
- log_channel_error(CS, Channel, Reason),
+handle_exception(State, Channel, Reason) ->
send_exception(State, Channel, Reason).
send_exception(State = #v1{connection = #connection{protocol = Protocol}},
Channel, Reason) ->
- {ShouldClose, CloseChannel, CloseMethod} =
+ {true, 0, CloseMethod} =
rabbit_binary_generator:map_exception(Channel, Reason, Protocol),
- NewState = case ShouldClose of
- true -> terminate_channels(),
- close_connection(State);
- false -> close_channel(Channel, State)
- end,
+ terminate_channels(),
+ State1 = close_connection(State),
ok = rabbit_writer:internal_send_command(
- NewState#v1.sock, CloseChannel, CloseMethod, Protocol),
- NewState.
+ State1#v1.sock, 0, CloseMethod, Protocol),
+ State1.
internal_emit_stats(State = #v1{stats_timer = StatsTimer}) ->
rabbit_event:notify(connection_stats, infos(?STATISTICS_KEYS, State)),