]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pbx_ael: Fix crash and lockup issue regarding 'ael reload'
authorMark Murawski <markm@intellasoft.net>
Tue, 31 Aug 2021 20:03:56 +0000 (16:03 -0400)
committerGeorge Joseph <gjoseph@digium.com>
Thu, 2 Sep 2021 19:16:08 +0000 (14:16 -0500)
Currently pbx_ael does not check if a reload is currently pending
before proceeding with a reload. This can cause multiple threads to
operate at the same time on what should be mutex protected data. This
change adds protection to reloading to ensure only one ael reload is
executing at a time.

ASTERISK-29609 #close

Change-Id: I5ed392ad226f6e4e7696ad742076d3e45c57af35

pbx/pbx_ael.c

index d55f2d42af81a44cb16b432227e761d4eea527ee..8bf3af0a8eb3e0b4d78f0fcf86d3be549b2393ad 100644 (file)
@@ -245,7 +245,13 @@ static char *handle_cli_ael_reload(struct ast_cli_entry *e, int cmd, struct ast_
        if (a->argc != 2)
                return CLI_SHOWUSAGE;
 
+#ifndef STANDALONE
+       /* Lock-Protected reload.  It is VERY BAD to have simultaneous ael load_module() executing at the same time */
+       return ast_module_reload("pbx_ael") == AST_MODULE_RELOAD_SUCCESS ? CLI_SUCCESS : CLI_FAILURE;
+#else
+       /* Lock-Protected reload not needed (and not available) when running standalone (Example: via aelparse cli tool).  No reload contention is possible */
        return (pbx_load_module() ? CLI_FAILURE : CLI_SUCCESS);
+#endif
 }
 
 static struct ast_cli_entry cli_ael[] = {
@@ -274,7 +280,13 @@ static int load_module(void)
 
 static int reload(void)
 {
+#ifndef STANDALONE
+       /* Lock-Protected reload.  It is VERY BAD to have simultaneous ael pbx_load_module() executing at the same time */
+       return ast_module_reload("pbx_ael") == AST_MODULE_RELOAD_SUCCESS ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE;
+#else
+       /* Lock-Protected reload not needed (and not available) when running standalone (Example: via aelparse cli tool).  No reload contention is possible */
        return pbx_load_module();
+#endif
 }
 
 #ifdef STANDALONE