res_pjsip: Remove ephemeral registered contacts on transport shutdown.
[asterisk/asterisk.git] / res / res_pjsip.c
index f3648ac..ca0c301 100644 (file)
                                <configOption name="rewrite_contact">
                                        <synopsis>Allow Contact header to be rewritten with the source IP address-port</synopsis>
                                        <description><para>
-                                               On inbound SIP messages from this endpoint, the Contact header or an appropriate Record-Route
-                                               header will be changed to have the source IP address and port. This option does not affect
-                                               outbound messages sent to this endpoint.
+                                               On inbound SIP messages from this endpoint, the Contact header or an
+                                               appropriate Record-Route header will be changed to have the source IP
+                                               address and port.  This option does not affect outbound messages sent to
+                                               this endpoint.  This option helps servers communicate with endpoints
+                                               that are behind NATs.  This option also helps reuse reliable transport
+                                               connections such as TCP and TLS.
                                        </para></description>
                                </configOption>
                                <configOption name="rtp_ipv6" default="no">
                                                in incoming SIP REGISTER requests and is not intended to be configured manually.
                                        </para></description>
                                </configOption>
+                               <configOption name="prune_on_boot">
+                                       <synopsis>A contact that cannot survive a restart/boot.</synopsis>
+                                       <description><para>
+                                               The option is set if the incoming SIP REGISTER contact is rewritten
+                                               on a reliable transport and is not intended to be configured manually.
+                                       </para></description>
+                               </configOption>
                        </configObject>
                        <configObject name="aor">
                                <synopsis>The configuration for a location of an endpoint</synopsis>
@@ -4662,6 +4672,7 @@ static int unload_pjsip(void *data)
                ast_sip_destroy_system();
                ast_sip_destroy_global_headers();
                internal_sip_unregister_service(&supplement_module);
+               ast_sip_destroy_transport_events();
        }
 
        if (monitor_thread) {
@@ -4740,7 +4751,6 @@ static int load_pjsip(void)
        return AST_MODULE_LOAD_SUCCESS;
 
 error:
-       unload_pjsip(NULL);
        return AST_MODULE_LOAD_DECLINE;
 }
 
@@ -4806,6 +4816,11 @@ static int load_module(void)
                goto error;
        }
 
+       if (ast_sip_initialize_transport_events()) {
+               ast_log(LOG_ERROR, "Failed to initialize SIP transport monitor. Aborting load\n");
+               goto error;
+       }
+
        ast_sip_initialize_dns();
 
        ast_sip_initialize_global_headers();