GitHub user andreareale opened a pull request:
https://github.com/apache/zookeeper/pull/662
ZOOKEEPER-3162
This PR fixes a few issues with the C client lock-recipe, as documented in
more detailed in
[ZOOKEEPER-3162](https://issues.apache.org/jira/browse/ZOOKEEPER-3162) on JIRA.
Details are also provided in the individual commits, but in short:
- Fix a bug in the choice of the predecessor node while trying to acquire
the lock
- Fix a possible deadlock in zkr_lock_operation
- Fix the return value of zkr_lock_lock to abide to the prescribed
semantics.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ibm-research-ireland/zookeeper ZOOKEEPER-3162
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/zookeeper/pull/662.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #662
----
commit f5b0e09820fa0713d64119e4ba70fe0d07533a96
Author: Andrea Reale <realean2@...>
Date: 2018-10-09T09:23:50Z
Fix wrong include path for C recipes
Signed-off-by: Andrea Reale <[email protected]>
commit d6e1953840f56c2c42948ff1958be779465e2bb9
Author: Andrea Reale <realean2@...>
Date: 2018-08-03T16:35:56Z
Bugfix on zookeeper-recipes-lock C implementation
- Fixes ZOOKEEPER-2408,ZOOKEEPER-2038, and (partly) ZOOKEEPER-2878
- Fixes child_floor by using strcmp_suffix instead of strcmp. This will
do the correct lookups within the sorted waiters list. Without this
the lock semantics are broken: e.g., assuming that session A < session
B (alfanumerically), if a thread from session B holds the lock, and a
thread from session A tries to acquire it it will find no predecessor
in child_floor and get the lock as well.
- Uses binary search to find child_floor (optimization)
Signed-off-by: Andrea Reale <[email protected]>
commit e95da861ba0340949baa65b6f143d8a4e67aee6c
Author: Andrea Reale <realean2@...>
Date: 2018-08-15T16:35:07Z
Fixes deadlock in zoo_lock_operation
zkr_lock_operation is always called by holding the mutex associated to
the client lock. In some cases, zkr_lock_operaton may decide to give-up
locking and call zkr_lock_unlock to release the lock. When this happens,
it will try to acquire again the same phtread mutex, which will lead to
a deadlock.
This commit fixes the issue by calling a non-protected version of
zkr_lock_unlock from within zkr_lock_operatino.
Signed-off-by: Andrea Reale <[email protected]>
commit 51ac01ecd06aca9d368519ff925a3539ddef35b4
Author: Andrea Reale <realean2@...>
Date: 2018-10-09T14:52:11Z
Fix return semantics of zkr_lock_lock
Returns 0 (on no-errors) from zkr_lock_lock. This matches the
API documentation. Additionall, returning zkr_lock_isowner is also
semantically wrong: a caller might be enqueued for lock acquision and
still not the owner; in such a case the function should still return 0
because that is the expected behavior.
Signed-off-by: Andrea Reale <[email protected]>
----
---