]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_musiconhold: Prevent multiple simultaneous reloads. 00/2000/3
authorSean Bright <sean.bright@gmail.com>
Wed, 13 Jan 2016 13:20:24 +0000 (08:20 -0500)
committerJoshua Colp <jcolp@digium.com>
Wed, 13 Jan 2016 13:41:19 +0000 (09:41 -0400)
There are two ways in which the reload() function in res_musiconhold can be
called from the CLI:

  * module reload res_musiconhold.so
  * moh reload

In the former case, the module loader holds a lock that prevents multiple
concurrent calls, but in the latter there is no such protection.

This patch changes the 'moh reload' CLI command to invoke the module loader
directly, rather than call reload() explicitly.

ASTERISK-25687 #close

Change-Id: I408968b4c8932864411b7f9ad88cfdc7b9ba711c

res/res_musiconhold.c

index 91724734e2ae62d8c52c9bac5a4e8c48867f99a8..1002633e24fb1f85c7005dd301303ad25ab45109 100644 (file)
@@ -67,6 +67,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/time.h"
 #include "asterisk/poll-compat.h"
 
+/* In order to gain access to ast_module_reload in 11 you need to include _private.h */
+#include "asterisk/_private.h"
+
 #define INITIAL_NUM_FILES   8
 #define HANDLE_REF     1
 #define DONT_UNREF     0
@@ -1836,7 +1839,8 @@ static char *handle_cli_moh_reload(struct ast_cli_entry *e, int cmd, struct ast_
        if (a->argc != e->args)
                return CLI_SHOWUSAGE;
 
-       reload();
+       /* The module loader will prevent concurrent reloads from occurring, so we delegate */
+       ast_module_reload("res_musiconhold");
 
        return CLI_SUCCESS;
 }