summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonyg@lshift.net>2008-07-03 13:59:36 +0100
committerTony Garnock-Jones <tonyg@lshift.net>2008-07-03 13:59:36 +0100
commitd0700a23d3ce0b787c0e5333e6f39e99ec663fc8 (patch)
tree7449cfde0076695cf945e8651892671e9ef910f9
parent675869a27714307bce377638dfe8f6a5f069e757 (diff)
downloadrabbitmq-server-bug18784.tar.gz
Migrate branch bug18784bug18784
-rw-r--r--src/rabbit_reader.erl3
-rw-r--r--src/rabbit_writer.erl11
2 files changed, 11 insertions, 3 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 1d11cbaa..bfd1ea72 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -59,6 +59,7 @@
%% all states, unless specified otherwise:
%% socket error -> *exit*
%% socket close -> *throw*
+%% writer send failure -> *throw*
%% forced termination -> *exit*
%% handshake_timeout -> *throw*
%% pre-init:
@@ -230,6 +231,8 @@ mainloop(Parent, Deb, State = #v1{sock= Sock, recv_ref = Ref}) ->
%% since this termination is initiated by our parent it is
%% probably more important to exit quickly.
exit(Reason);
+ {'EXIT', _Pid, E = {writer, send_failed, _Error}} ->
+ throw(E);
{'EXIT', Pid, Reason} ->
mainloop(Parent, Deb, handle_dependent_exit(Pid, Reason, State));
{terminate_channel, Channel, Ref1} ->
diff --git a/src/rabbit_writer.erl b/src/rabbit_writer.erl
index eda871ec..0f6bca91 100644
--- a/src/rabbit_writer.erl
+++ b/src/rabbit_writer.erl
@@ -153,10 +153,15 @@ internal_send_command(Sock, Channel, MethodRecord, Content, FrameMax) ->
%% when these are full. So the fact that we process the result
%% asynchronously does not impact flow control.
internal_send_command_async(Sock, Channel, MethodRecord) ->
- true = erlang:port_command(Sock, assemble_frames(Channel, MethodRecord)),
+ true = port_cmd(Sock, assemble_frames(Channel, MethodRecord)),
ok.
internal_send_command_async(Sock, Channel, MethodRecord, Content, FrameMax) ->
- true = erlang:port_command(Sock, assemble_frames(Channel, MethodRecord,
- Content, FrameMax)),
+ true = port_cmd(Sock, assemble_frames(Channel, MethodRecord,
+ Content, FrameMax)),
ok.
+
+port_cmd(Sock, Data) ->
+ try erlang:port_command(Sock, Data)
+ catch error:Error -> exit({writer, send_failed, Error})
+ end.