<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15277">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_voicemail: Prevent deadlocks when out of ODBC database connections<br><br>ASTERISK-28992 #close<br><br>Change-Id: Ia7d608924036139ee2520b840d077762d02668d0<br>---<br>M apps/app_voicemail.c<br>1 file changed, 10 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 1bb736b..2929cf2 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -3834,6 +3834,7 @@</span><br><span> char fn[PATH_MAX];</span><br><span> char full_fn[PATH_MAX];</span><br><span> char msgnums[80];</span><br><span style="color: hsl(120, 100%, 40%);">+ char msg_id[MSG_ID_LEN] = "";</span><br><span> char *argv[] = { dir, msgnums };</span><br><span> struct generic_prepare_struct gps = { .sql = sql, .argc = 2, .argv = argv };</span><br><span> struct odbc_obj *obj;</span><br><span>@@ -3938,10 +3939,10 @@</span><br><span> } else {</span><br><span> res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);</span><br><span> if (res == SQL_NULL_DATA && !strcasecmp(coltitle, "msg_id")) {</span><br><span style="color: hsl(0, 100%, 40%);">- char msg_id[MSG_ID_LEN];</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Generate msg_id now, but don't store it until we're done with this</span><br><span style="color: hsl(120, 100%, 40%);">+ connection */</span><br><span> generate_msg_id(msg_id);</span><br><span> snprintf(rowdata, sizeof(rowdata), "%s", msg_id);</span><br><span style="color: hsl(0, 100%, 40%);">- odbc_update_msg_id(dir, msgnum, msg_id);</span><br><span> } else if (res == SQL_NULL_DATA && !strcasecmp(coltitle, "category")) {</span><br><span> /* Ignore null column value for category */</span><br><span> ast_debug(3, "Ignoring null category column in ODBC voicemail retrieve_file.\n");</span><br><span>@@ -3967,6 +3968,13 @@</span><br><span> </span><br><span> ast_odbc_release_obj(obj);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* If res_odbc is configured to only allow a single database connection, we</span><br><span style="color: hsl(120, 100%, 40%);">+ will deadlock if we try to do this before releasing the connection we</span><br><span style="color: hsl(120, 100%, 40%);">+ were just using. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(msg_id)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ odbc_update_msg_id(dir, msgnum, msg_id);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return x - 1;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15277">change 15277</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/+/15277"/><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: Ia7d608924036139ee2520b840d077762d02668d0 </div>
<div style="display:none"> Gerrit-Change-Number: 15277 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>