Avoid losing messages when the socket closes abruptly by calling
authorTony Garnock-Jones <tonyg@lshift.net>
Wed Apr 30 16:48:11 2008 +0100 (2008-04-30)
changeset 26b37faa511709
parent 25 36fad000db32
child 27 9e742c9cf454
child 29 c56fa103fa0c
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.1 --- a/src/rabbit_stomp.erl	Wed Apr 30 15:05:33 2008 +0100
     1.2 +++ b/src/rabbit_stomp.erl	Wed Apr 30 16:48:11 2008 +0100
     1.3 @@ -105,7 +105,13 @@
     1.4  	{tcp, _Sock, Bytes} ->
     1.5  	    process_received_bytes(Bytes, State);
     1.6  	{tcp_closed, _Sock} ->
     1.7 -	    done;
     1.8 +	    case State#state.channel of
     1.9 +		none ->
    1.10 +		    done;
    1.11 +		ChPid ->
    1.12 +		    rabbit_channel:shutdown(ChPid),
    1.13 +		    ?MODULE:mainloop(State)
    1.14 +	    end;
    1.15  	{send_command, Command} ->
    1.16  	    ?MODULE:mainloop(send_reply(Command, State));
    1.17  	{send_command_and_notify, QPid, TxPid, Method, Content} ->