@@ -282,8 +282,10 @@ recvloop(Deb, State = #v1{connection_state = blocked}) ->
282282 mainloop (Deb , State );
283283recvloop (Deb , State = # v1 {sock = Sock , recv_len = RecvLen , buf_len = BufLen })
284284 when BufLen < RecvLen ->
285- ok = rabbit_net :setopts (Sock , [{active , once }]),
286- mainloop (Deb , State # v1 {pending_recv = true });
285+ case rabbit_net :setopts (Sock , [{active , once }]) of
286+ ok -> mainloop (Deb , State # v1 {pending_recv = true });
287+ {error , Reason } -> stop (Reason , State )
288+ end ;
287289recvloop (Deb , State = # v1 {recv_len = RecvLen , buf = Buf , buf_len = BufLen }) ->
288290 {Data , Rest } = split_binary (case Buf of
289291 [B ] -> B ;
@@ -302,11 +304,9 @@ mainloop(Deb, State = #v1{sock = Sock, buf = Buf, buf_len = BufLen}) ->
302304 closed when State # v1 .connection_state =:= closed ->
303305 ok ;
304306 closed ->
305- maybe_emit_stats (State ),
306- throw (connection_closed_abruptly );
307+ stop (closed , State );
307308 {error , Reason } ->
308- maybe_emit_stats (State ),
309- throw ({inet_error , Reason });
309+ stop (Reason , State );
310310 {other , {system , From , Request }} ->
311311 sys :handle_system_msg (Request , From , State # v1 .parent ,
312312 ? MODULE , Deb , State );
@@ -317,6 +317,11 @@ mainloop(Deb, State = #v1{sock = Sock, buf = Buf, buf_len = BufLen}) ->
317317 end
318318 end .
319319
320+ stop (closed , State ) -> maybe_emit_stats (State ),
321+ throw (connection_closed_abruptly );
322+ stop (Reason , State ) -> maybe_emit_stats (State ),
323+ throw ({inet_error , Reason }).
324+
320325handle_other ({conserve_resources , Source , Conserve },
321326 State = # v1 {throttle = Throttle =
322327 # throttle {alarmed_by = CR }}) ->
0 commit comments