@@ -273,18 +273,10 @@ handle_info({timeout, TRef, activate_sock}, State = #state{limit_timer = TRef})
273
273
{noreply , activate_sock (NState )};
274
274
275
275
handle_info ({'DOWN' , _MRef , process , DownPid , _Reason }, State = # state {peers = Peers }) ->
276
- case maps :find (DownPid , Peers ) of
277
- {ok , Peer } ->
278
- {noreply , erase_peer (Peer , DownPid , State )};
279
- error -> {noreply , State }
280
- end ;
276
+ handle_peer_down (DownPid , Peers , State );
281
277
282
278
handle_info ({'EXIT' , DownPid , _Reason }, State = # state {peers = Peers }) ->
283
- case maps :find (DownPid , Peers ) of
284
- {ok , Peer } ->
285
- {noreply , erase_peer (Peer , DownPid , State )};
286
- error -> {noreply , State }
287
- end ;
279
+ handle_peer_down (DownPid , Peers , State );
288
280
289
281
handle_info ({datagram , Peer = {IP , Port }, Packet }, State = # state {sock = Sock }) ->
290
282
case gen_udp :send (Sock , IP , Port , Packet ) of
@@ -293,7 +285,6 @@ handle_info({datagram, Peer = {IP, Port}, Packet}, State = #state{sock = Sock})
293
285
? ERROR_MSG (" Dropped packet to: ~s , reason: ~s " , [esockd :format (Peer ), Reason ])
294
286
end ,
295
287
{noreply , State };
296
-
297
288
handle_info (Info , State ) ->
298
289
? ERROR_MSG (" Unexpected info: ~p " , [Info ]),
299
290
{noreply , State }.
@@ -308,6 +299,14 @@ code_change(_OldVsn, State, _Extra) ->
308
299
% % Internel functions
309
300
% %--------------------------------------------------------------------
310
301
302
+ handle_peer_down (DownPid , Peers , State ) ->
303
+ case maps :find (DownPid , Peers ) of
304
+ {ok , Peer } ->
305
+ {noreply , erase_peer (Peer , DownPid , State )};
306
+ error ->
307
+ {noreply , State }
308
+ end .
309
+
311
310
- compile ({inline ,
312
311
[ allowed / 2
313
312
, should_throttle / 1
0 commit comments