Skip to content

Commit f66f77f

Browse files
InterLinked1gtjoseph
authored andcommitted
res_pjsip_pubsub: Prevent removing subscriptions.
pjproject does not provide any mechanism of removing event packages, which means that once a subscription handler is registered, it is effectively permanent. pjproject will assert if the same event package is ever registered again, so currently unloading and loading any Asterisk modules that use subscriptions will cause a crash that is beyond our control. For that reason, we now prevent users from being able to unload these modules, to prevent them from ever being loaded twice. ASTERISK-30264 #close Change-Id: I7fdcb1a5e44d38b7ba10c44259fe98f0ae9bc12c
1 parent 0825d26 commit f66f77f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

res/res_pjsip_exten_state.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ static int publisher_stop(struct ast_sip_outbound_publish_client *client)
973973

974974
static int unload_module(void)
975975
{
976+
#if 0
976977
ast_sip_unregister_event_publisher_handler(&dialog_publisher);
977978
ast_sip_unregister_subscription_handler(&dialog_handler);
978979
ast_sip_unregister_event_publisher_handler(&presence_publisher);
@@ -987,6 +988,18 @@ static int unload_module(void)
987988
publishers = NULL;
988989

989990
return 0;
991+
#else
992+
/* If we were allowed to unload, the above is what we would do.
993+
* pjsip_evsub_register_pkg is called by ast_sip_register_subscription_handler
994+
* but there is no corresponding unregister function, so unloading
995+
* a module does not remove the event package. If this module is ever
996+
* loaded again, then pjproject will assert and cause a crash.
997+
* For that reason, we must not be allowed to unload, but if
998+
* a pjsip_evsub_unregister_pkg API is added in the future
999+
* then we should go back to unloading the module as intended.
1000+
*/
1001+
return -1;
1002+
#endif
9901003
}
9911004

9921005
static int load_module(void)

res/res_pjsip_mwi.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ static int reload(void)
15241524

15251525
static int unload_module(void)
15261526
{
1527+
#if 0
15271528
struct ao2_container *unsolicited_mwi;
15281529

15291530
ast_sorcery_observer_remove(ast_sip_get_sorcery(), "global", &global_observer);
@@ -1548,6 +1549,18 @@ static int unload_module(void)
15481549
ast_free(default_voicemail_extension);
15491550
default_voicemail_extension = NULL;
15501551
return 0;
1552+
#else
1553+
/* If we were allowed to unload, the above is what we would do.
1554+
* pjsip_evsub_register_pkg is called by ast_sip_register_subscription_handler
1555+
* but there is no corresponding unregister function, so unloading
1556+
* a module does not remove the event package. If this module is ever
1557+
* loaded again, then pjproject will assert and cause a crash.
1558+
* For that reason, we must not be allowed to unload, but if
1559+
* a pjsip_evsub_unregister_pkg API is added in the future
1560+
* then we should go back to unloading the module as intended.
1561+
*/
1562+
return -1;
1563+
#endif
15511564
}
15521565

15531566
static int load_module(void)

0 commit comments

Comments
 (0)