]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Format Interfaces: Prevent unload except by shutdown. 51/351/1
authorCorey Farrell <git@cfware.com>
Mon, 4 May 2015 02:03:13 +0000 (22:03 -0400)
committerCorey Farrell <git@cfware.com>
Mon, 4 May 2015 02:08:14 +0000 (22:08 -0400)
Format interfaces cannot be unregistered, so the modules that provide them
need to be held open except by shutdown.

ASTERISK-25054 #close
Reported by: Corey Farrell

Change-Id: Iadbd9675bf0d30b8fded5a739b163db3ea2db8f3

main/format.c

index 3e1ee866ec3b042358193022bf5a8b1b0eb938d1..148c77f8d86ac92d31e193a69d3fbce755c81e59 100644 (file)
@@ -36,6 +36,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/format.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"
+#include "asterisk/module.h"
 
 /*! \brief Number of buckets to use for format interfaces (should be prime for performance reasons) */
 #define FORMAT_INTERFACE_BUCKETS 53
@@ -156,6 +157,8 @@ int __ast_format_interface_register(const char *codec, const struct ast_format_i
        format_interface->interface = interface;
        strcpy(format_interface->codec, codec); /* Safe */
 
+       /* Once registered a format interface cannot be unregistered. */
+       ast_module_shutdown_ref(mod);
        ao2_link_flags(interfaces, format_interface, OBJ_NOLOCK);
        ao2_ref(format_interface, -1);