[Asterisk-code-review] pbx_ael: Fix crash and lockup issue regarding 'ael reload' (asterisk[16])

George Joseph asteriskteam at digium.com
Thu Sep 2 14:15:59 CDT 2021


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16356 )

Change subject: pbx_ael:  Fix crash and lockup issue regarding 'ael reload'
......................................................................

pbx_ael:  Fix crash and lockup issue regarding 'ael reload'

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
---
M pbx/pbx_ael.c
1 file changed, 12 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c
index d55f2d4..8bf3af0 100644
--- a/pbx/pbx_ael.c
+++ b/pbx/pbx_ael.c
@@ -245,7 +245,13 @@
 	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 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

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16356
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I5ed392ad226f6e4e7696ad742076d3e45c57af35
Gerrit-Change-Number: 16356
Gerrit-PatchSet: 4
Gerrit-Owner: Mark Murawski <markm at intellasoft.net>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210902/3c391eb5/attachment-0001.html>


More information about the asterisk-code-review mailing list