Avoid losing messages when the socket closes abruptly by calling
authorTony Garnock-Jones <tonyg@lshift.net>
Wed Apr 30 16:48:11 2008 +0100 (12 days ago)
changeset 26b37faa511709
parent 2536fad000db32
child 279e742c9cf454
child 29c56fa103fa0c
Avoid losing messages when the socket closes abruptly by calling
rabbit_channel:shutdown/1, which nicely processes all the pending work
before notifying us of channel closure.
src/rabbit_stomp.erl
       1 --- a/src/rabbit_stomp.erl	Wed Apr 30 15:05:33 2008 +0100
       2 +++ b/src/rabbit_stomp.erl	Wed Apr 30 16:48:11 2008 +0100
       3 @@ -105,7 +105,13 @@
       4  	{tcp, _Sock, Bytes} ->
       5  	    process_received_bytes(Bytes, State);
       6  	{tcp_closed, _Sock} ->
       7 -	    done;
       8 +	    case State#state.channel of
       9 +		none ->
      10 +		    done;
      11 +		ChPid ->
      12 +		    rabbit_channel:shutdown(ChPid),
      13 +		    ?MODULE:mainloop(State)
      14 +	    end;
      15  	{send_command, Command} ->
      16  	    ?MODULE:mainloop(send_reply(Command, State));
      17  	{send_command_and_notify, QPid, TxPid, Method, Content} ->