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

Jaco Kroon asteriskteam at digium.com
Sat May 22 07:51:29 CDT 2021


Jaco Kroon has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/15944/1

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: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210522/f4bde6c2/attachment-0001.html>


More information about the asterisk-code-review mailing list