]> granicus.if.org Git - ejabberd/commitdiff
Don't forget to close socket of timed out flow
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 12 Jun 2014 05:27:32 +0000 (09:27 +0400)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 12 Jun 2014 05:30:04 +0000 (09:30 +0400)
src/mod_sip_registrar.erl

index 7233d053b85851706cb83943bfedad558f7c8dfc..9f52436037f3c5de08f23998979f380499b49ee2 100644 (file)
@@ -321,6 +321,11 @@ delete_expired_session(US, TRef) ->
              fun(#sip_session{reg_tref = T1,
                               flow_tref = T2} = Session)
                    when T1 == TRef; T2 == TRef ->
+                     if T2 /= undefined ->
+                             close_socket(Session);
+                        true ->
+                             ok
+                     end,
                      delete_session(Session);
                 (_) ->
                      ok
@@ -518,6 +523,13 @@ set_monitor_and_timer(#sip_session{socket = #sip_socket{type = Type,
 set_timer(#sip_session{us = US}, Timeout) ->
     erlang:start_timer(Timeout * 1000, self(), US).
 
+close_socket(#sip_session{socket = SIPSocket}) ->
+    if SIPSocket#sip_socket.type /= udp ->
+           esip_socket:close(SIPSocket);
+       true ->
+           ok
+    end.
+
 delete_session(#sip_session{reg_tref = RegTRef,
                            flow_tref = FlowTRef,
                            conn_mref = MRef} = Session) ->