[Asterisk-code-review] cli: Prevent assertions on startup from bad ao2 refs. (asterisk[master])

N A asteriskteam at digium.com
Tue May 3 08:00:18 CDT 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18523 )


Change subject: cli: Prevent assertions on startup from bad ao2 refs.
......................................................................

cli: Prevent assertions on startup from bad ao2 refs.

If "core show channels" is run before startup has completed, it
is possible for bad ao2 refs to occur because the system is not
yet fully initialized. This will lead to an assertion failing.

To prevent this, we now sleep and wait for Asterisk to be fully
booted before any channel container access is attempted.

ASTERISK-29846 #close

Change-Id: If6b3cde802876bd738c1b4cf2683bea6ddc615b6
---
M main/cli.c
1 file changed, 5 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/23/18523/1

diff --git a/main/cli.c b/main/cli.c
index 0c11953..2dc8820 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1139,6 +1139,11 @@
 	} else if (a->argc != e->args - 1)
 		return CLI_SHOWUSAGE;
 
+	/* Don't attempt to iterate channels if startup is not complete. */
+	while (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
+		usleep(1000);
+	}
+
 	channels = ast_channel_cache_by_name();
 
 	if (!count) {

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: If6b3cde802876bd738c1b4cf2683bea6ddc615b6
Gerrit-Change-Number: 18523
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220503/4e76c893/attachment.html>


More information about the asterisk-code-review mailing list