<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18593">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader: Prevent deadlock using tab completion.<br><br>If tab completion using ast_module_helper is attempted<br>during startup, deadlock will ensue because the CLI<br>will attempt to lock the module list while it is already<br>locked by the loader. This causes deadlock because when<br>the loader tries to acquire the CLI lock, they are blocked<br>on each other.<br><br>Waiting for startup to complete is not feasible because<br>the CLI lock is acquired while waiting, so deadlock will<br>ensure regardless of whether or not a lock on the module<br>list is attempted.<br><br>To prevent deadlock, we immediately abort if tab completion<br>is attempted on the module list before Asterisk is fully<br>booted.<br><br>ASTERISK-30039 #close<br><br>Change-Id: Idd468906c512bb196631e366a8f597a0e2e9271d<br>---<br>M include/asterisk/module.h<br>M main/loader.c<br>2 files changed, 6 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/93/18593/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/module.h b/include/asterisk/module.h</span><br><span>index cce8735..f79dc8e 100644</span><br><span>--- a/include/asterisk/module.h</span><br><span>+++ b/include/asterisk/module.h</span><br><span>@@ -283,7 +283,7 @@</span><br><span>  * \param type The type of action that will be performed by CLI.</span><br><span>  *</span><br><span>  * \retval A possible completion of the partial match.</span><br><span style="color: hsl(0, 100%, 40%);">- * \retval NULL if no matches were found.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval NULL if no matches were found or Asterisk is not yet fully booted.</span><br><span>  */</span><br><span> char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, enum ast_module_helper_type type);</span><br><span> </span><br><span>diff --git a/main/loader.c b/main/loader.c</span><br><span>index 4c6c2a8..549e3f0 100644</span><br><span>--- a/main/loader.c</span><br><span>+++ b/main/loader.c</span><br><span>@@ -1382,6 +1382,11 @@</span><br><span>              return NULL;</span><br><span>         }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Tab completion can't be used during startup, or CLI and loader will deadlock. */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (!ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {</span><br><span style="color: hsl(120, 100%, 40%);">+            return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if (type == AST_MODULE_HELPER_LOAD) {</span><br><span>                module_load_helper(word);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18593">change 18593</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18593"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: Idd468906c512bb196631e366a8f597a0e2e9271d </div>
<div style="display:none"> Gerrit-Change-Number: 18593 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>