<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17984">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
Kevin Harwell: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">manager.c: Simplify AMI ModuleCheck handling<br><br>This code was needlessly complex and would fail to properly delimit<br>the response message if LOW_MEMORY was defined.<br><br>Change-Id: Iae50bf09ef4bc34f9dc4b49435daa76f8b2c5b6e<br>---<br>M main/manager.c<br>1 file changed, 13 insertions(+), 19 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/manager.c b/main/manager.c</span><br><span>index 129ef38..588f144 100644</span><br><span>--- a/main/manager.c</span><br><span>+++ b/main/manager.c</span><br><span>@@ -6469,36 +6469,30 @@</span><br><span> /*! \brief Manager function to check if module is loaded */</span><br><span> static int manager_modulecheck(struct mansession *s, const struct message *m)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- int res;</span><br><span> const char *module = astman_get_header(m, "Module");</span><br><span> const char *id = astman_get_header(m, "ActionID");</span><br><span style="color: hsl(0, 100%, 40%);">- char idText[256];</span><br><span style="color: hsl(0, 100%, 40%);">- char filename[PATH_MAX];</span><br><span style="color: hsl(0, 100%, 40%);">- char *cut;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(filename, module, sizeof(filename));</span><br><span style="color: hsl(0, 100%, 40%);">- if ((cut = strchr(filename, '.'))) {</span><br><span style="color: hsl(0, 100%, 40%);">- *cut = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- cut = filename + strlen(filename);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- snprintf(cut, (sizeof(filename) - strlen(filename)) - 1, ".so");</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "**** ModuleCheck .so file %s\n", filename);</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_module_check(filename);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!res) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "**** ModuleCheck .so file %s\n", module);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_module_check(module)) {</span><br><span> astman_send_error(s, m, "Module not loaded");</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ astman_append(s, "Response: Success\r\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (!ast_strlen_zero(id)) {</span><br><span style="color: hsl(0, 100%, 40%);">- snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- idText[0] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+ astman_append(s, "ActionID: %s\r\n", id);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- astman_append(s, "Response: Success\r\n%s", idText);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #if !defined(LOW_MEMORY)</span><br><span style="color: hsl(0, 100%, 40%);">- astman_append(s, "Version: %s\r\n\r\n", "");</span><br><span style="color: hsl(120, 100%, 40%);">+ /* When we switched from subversion to git we lost the ability to</span><br><span style="color: hsl(120, 100%, 40%);">+ * retrieve the 'ASTERISK_FILE_VERSION' from that file, but we retain</span><br><span style="color: hsl(120, 100%, 40%);">+ * the response header here for backwards compatibility. */</span><br><span style="color: hsl(120, 100%, 40%);">+ astman_append(s, "Version: \r\n");</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ astman_append(s, "\r\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17984">change 17984</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/+/17984"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iae50bf09ef4bc34f9dc4b49435daa76f8b2c5b6e </div>
<div style="display:none"> Gerrit-Change-Number: 17984 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>