diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2014-01-20 20:21:41 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2014-01-20 20:21:41 +0000 |
| commit | 219dd70ac7b83da1fd899d35ac5c9c6401e281c8 (patch) | |
| tree | ffab4e341f4175a35f935070e4e61fed1c6e9ae2 | |
| parent | d3cddfd66ab5bc8265f268a3b7d54b79bbf7a9f8 (diff) | |
| download | rabbitmq-server-git-219dd70ac7b83da1fd899d35ac5c9c6401e281c8.tar.gz | |
handle setopts error gracefully
| -rw-r--r-- | src/rabbit_reader.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index f50d8999f7..1ae9bacf8e 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -282,8 +282,10 @@ recvloop(Deb, State = #v1{connection_state = blocked}) -> mainloop(Deb, State); recvloop(Deb, State = #v1{sock = Sock, recv_len = RecvLen, buf_len = BufLen}) when BufLen < RecvLen -> - ok = rabbit_net:setopts(Sock, [{active, once}]), - mainloop(Deb, State#v1{pending_recv = true}); + case rabbit_net:setopts(Sock, [{active, once}]) of + ok -> mainloop(Deb, State#v1{pending_recv = true}); + {error, Reason} -> stop(Reason, State) + end; recvloop(Deb, State = #v1{recv_len = RecvLen, buf = Buf, buf_len = BufLen}) -> {Data, Rest} = split_binary(case Buf of [B] -> B; @@ -302,11 +304,9 @@ mainloop(Deb, State = #v1{sock = Sock, buf = Buf, buf_len = BufLen}) -> closed when State#v1.connection_state =:= closed -> ok; closed -> - maybe_emit_stats(State), - throw(connection_closed_abruptly); + stop(closed, State); {error, Reason} -> - maybe_emit_stats(State), - throw({inet_error, Reason}); + stop(Reason, State); {other, {system, From, Request}} -> sys:handle_system_msg(Request, From, State#v1.parent, ?MODULE, Deb, State); @@ -317,6 +317,11 @@ mainloop(Deb, State = #v1{sock = Sock, buf = Buf, buf_len = BufLen}) -> end end. +stop(closed, State) -> maybe_emit_stats(State), + throw(connection_closed_abruptly); +stop(Reason, State) -> maybe_emit_stats(State), + throw({inet_error, Reason}). + handle_other({conserve_resources, Source, Conserve}, State = #v1{throttle = Throttle = #throttle{alarmed_by = CR}}) -> |
