]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a logic flaw in the code that stores lock info which is displayed
authorMark Michelson <mmichelson@digium.com>
Mon, 17 Mar 2008 22:05:49 +0000 (22:05 +0000)
committerMark Michelson <mmichelson@digium.com>
Mon, 17 Mar 2008 22:05:49 +0000 (22:05 +0000)
via the "core show locks" command. The idea behind this section of code was
to remove the previous lock from the list if it was a trylock that had failed.
Unfortunately, instead of checking the status of the previous lock, we were referencing
the index immediately following the previous lock in the lock_info->locks array.
The result of this problem, under the right circumstances, was that the lock which
we currently in the process of attempting to acquire could "overwrite" the previous lock
which was acquired. While this does not in any way affect typical operation, it *could*
lead to misleading "core show locks" output.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@109226 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/utils.c

index 755789c7211e3a3b6463ff3ff0418ade1f4496fa..36fd0d1baf8a0e620cf6c438e19b4aa4bfa4546d 100644 (file)
@@ -611,7 +611,7 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
                return;
        }
 
-       if (i && lock_info->locks[i].pending == -1) {
+       if (i && lock_info->locks[i-1].pending == -1) {
                /* The last lock on the list was one that this thread tried to lock but
                 * failed at doing so.  It has now moved on to something else, so remove
                 * the old lock from the list. */