Update listener restart in IP change: don't create/restart listener if currently no listener, also update docs that bound address setting will be reset. (#3873)

This commit is contained in:
Nanang Izzuddin 2024-03-15 09:41:16 +07:00 committed by GitHub
parent ed40439b0d
commit a974061441
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 3 deletions

View File

@ -2787,6 +2787,9 @@ typedef struct pjsua_ip_change_param
{
/**
* If set to PJ_TRUE, this will restart the transport listener.
* Note that if restarting listener is enabled and the listener is
* configured with a bound address, the address will be reset
* so it will bind to any address (e.g: IPv4 "0.0.0.0" or IPv6 "::").
*
* Default : PJ_TRUE
*/

View File

@ -1744,6 +1744,22 @@ PJ_DEF(pj_status_t) pjsip_tcp_transport_restart(pjsip_tpfactory *factory,
pj_status_t status = PJ_SUCCESS;
struct tcp_listener *listener = (struct tcp_listener *)factory;
/* Just update the published address if currently no listener */
if (!listener->asock) {
PJ_LOG(3,(factory->obj_name,
"TCP restart requested while no listener created, "
"update the published address only"));
status = update_factory_addr(listener, a_name);
if (status != PJ_SUCCESS)
return status;
/* Set transport info. */
update_transport_info(listener);
return PJ_SUCCESS;
}
lis_close(listener);
status = pjsip_tcp_transport_lis_start(factory, local, a_name);
@ -1753,15 +1769,15 @@ PJ_DEF(pj_status_t) pjsip_tcp_transport_restart(pjsip_tpfactory *factory,
return status;
}
status = pjsip_tpmgr_register_tpfactory(listener->tpmgr,
&listener->factory);
if (status != PJ_SUCCESS) {
tcp_perror(listener->factory.obj_name,
"Unable to register the transport listener", status);
} else {
listener->is_registered = PJ_TRUE;
}
listener->is_registered = PJ_TRUE;
}
return status;
}

View File

@ -756,6 +756,22 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_restart(pjsip_tpfactory *factory,
pj_status_t status = PJ_SUCCESS;
struct tls_listener *listener = (struct tls_listener *)factory;
/* Just update the published address if currently no listener */
if (!listener->ssock) {
PJ_LOG(3,(factory->obj_name,
"TLS restart requested while no listener created, "
"update the published address only"));
status = update_factory_addr(listener, a_name);
if (status != PJ_SUCCESS)
return status;
/* Set transport info. */
update_transport_info(listener);
return PJ_SUCCESS;
}
lis_close(listener);
status = pjsip_tls_transport_lis_start(factory, local, a_name);