[Asterisk-code-review] loader: Prevent deadlock using tab completion. (asterisk[19])
Kevin Harwell
asteriskteam at digium.com
Mon Jun 6 16:51:56 CDT 2022
Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18593 )
Change subject: loader: Prevent deadlock using tab completion.
......................................................................
loader: Prevent deadlock using tab completion.
If tab completion using ast_module_helper is attempted
during startup, deadlock will ensue because the CLI
will attempt to lock the module list while it is already
locked by the loader. This causes deadlock because when
the loader tries to acquire the CLI lock, they are blocked
on each other.
Waiting for startup to complete is not feasible because
the CLI lock is acquired while waiting, so deadlock will
ensure regardless of whether or not a lock on the module
list is attempted.
To prevent deadlock, we immediately abort if tab completion
is attempted on the module list before Asterisk is fully
booted.
ASTERISK-30039 #close
Change-Id: Idd468906c512bb196631e366a8f597a0e2e9271d
---
M include/asterisk/module.h
M main/loader.c
2 files changed, 6 insertions(+), 1 deletion(-)
Approvals:
Kevin Harwell: Looks good to me, approved; Approved for Submit
Benjamin Keith Ford: Looks good to me, but someone else must approve
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index cce8735..f79dc8e 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -283,7 +283,7 @@
* \param type The type of action that will be performed by CLI.
*
* \retval A possible completion of the partial match.
- * \retval NULL if no matches were found.
+ * \retval NULL if no matches were found or Asterisk is not yet fully booted.
*/
char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, enum ast_module_helper_type type);
diff --git a/main/loader.c b/main/loader.c
index 4c6c2a8..549e3f0 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -1382,6 +1382,11 @@
return NULL;
}
+ /* Tab completion can't be used during startup, or CLI and loader will deadlock. */
+ if (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
+ return NULL;
+ }
+
if (type == AST_MODULE_HELPER_LOAD) {
module_load_helper(word);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18593
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: Idd468906c512bb196631e366a8f597a0e2e9271d
Gerrit-Change-Number: 18593
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220606/ca8ba64e/attachment.html>
More information about the asterisk-code-review
mailing list