[Asterisk-code-review] func_lock: Fix requesters counter in error paths. (asterisk[master])

Friendly Automation asteriskteam at digium.com
Fri Jun 11 12:37:12 CDT 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15944 )

Change subject: func_lock: Fix requesters counter in error paths.
......................................................................

func_lock: Fix requesters counter in error paths.

In two places we bail out with failure after we've already incremented
the requesters counter, if this occured then it would effectively result
in unload to wait indefinitely, thus preventing clean shutdown.

Change-Id: I362a6c0dc424f736d4a9c733d818e72d19675283
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
M funcs/func_lock.c
1 file changed, 9 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/funcs/func_lock.c b/funcs/func_lock.c
index 0726407..ad4d58e 100644
--- a/funcs/func_lock.c
+++ b/funcs/func_lock.c
@@ -268,7 +268,13 @@
 
 	if (!clframe) {
 		if (unloading) {
+			ast_log(LOG_ERROR,
+				"Busy unloading.  %sLOCK will fail.\n",
+				trylock ? "TRY" : "");
 			/* Don't bother */
+			ast_mutex_lock(&current->mutex);
+			current->requesters--;
+			ast_mutex_unlock(&current->mutex);
 			AST_LIST_UNLOCK(list);
 			return -1;
 		}
@@ -277,6 +283,9 @@
 			ast_log(LOG_ERROR,
 				"Unable to allocate channel lock frame.  %sLOCK will fail.\n",
 				trylock ? "TRY" : "");
+			ast_mutex_lock(&current->mutex);
+			current->requesters--;
+			ast_mutex_unlock(&current->mutex);
 			AST_LIST_UNLOCK(list);
 			return -1;
 		}

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I362a6c0dc424f736d4a9c733d818e72d19675283
Gerrit-Change-Number: 15944
Gerrit-PatchSet: 2
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
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/20210611/8d69dfac/attachment.html>


More information about the asterisk-code-review mailing list