* Change __ast_module_shutdown_ref to be NULL safe (11+).
* Allow modules that call ast_bucket_scheme_register or ast_codec_register
to be unloaded during graceful shutdown only (13+ only).
ASTERISK-24796 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4428/
........
Merged revisions 432058 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 432059 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432060
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
ast_verb(2, "Registered bucket scheme '%s'\n", name);
- ast_module_ref(module);
+ ast_module_shutdown_ref(module);
return 0;
}
ao2_link_flags(codecs, codec_new, OBJ_NOLOCK);
- /* Once registered a codec can not be unregistered, and the module must persist */
- ast_module_ref(mod);
+ /* Once registered a codec can not be unregistered, and the module must persist until shutdown */
+ ast_module_shutdown_ref(mod);
ast_verb(2, "Registered '%s' codec '%s' at sample rate '%u' with id '%u'\n",
ast_codec_media_type2str(codec->type), codec->name, codec->sample_rate, codec_new->id);
void __ast_module_shutdown_ref(struct ast_module *mod, const char *file, int line, const char *func)
{
- if (!mod->flags.keepuntilshutdown) {
- __ast_module_ref(mod, file, line, func);
- mod->flags.keepuntilshutdown = 1;
+ if (!mod || mod->flags.keepuntilshutdown) {
+ return;
}
+
+ __ast_module_ref(mod, file, line, func);
+ mod->flags.keepuntilshutdown = 1;
}
void __ast_module_unref(struct ast_module *mod, const char *file, int line, const char *func)