* Fixed CID 1262: waitForLock was not only -1 when exiting the loop, it didn't
make much sense to wake up any waiters either in this case. * Fixed doubled semaphore deletion. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38418 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1563,8 +1563,6 @@ release_advisory_lock(struct vnode* vnode, struct flock* flock)
|
|||||||
|
|
||||||
// we've detached the locking from the vnode, so we can
|
// we've detached the locking from the vnode, so we can
|
||||||
// safely delete it
|
// safely delete it
|
||||||
delete_sem(locking->lock);
|
|
||||||
delete_sem(locking->wait_sem);
|
|
||||||
delete locking;
|
delete locking;
|
||||||
} else {
|
} else {
|
||||||
// the locking is in use again
|
// the locking is in use again
|
||||||
@@ -1601,7 +1599,6 @@ acquire_advisory_lock(struct vnode* vnode, pid_t session, struct flock* flock,
|
|||||||
// TODO: do deadlock detection!
|
// TODO: do deadlock detection!
|
||||||
|
|
||||||
struct advisory_locking* locking;
|
struct advisory_locking* locking;
|
||||||
sem_id waitForLock;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// if this vnode has an advisory_locking structure attached,
|
// if this vnode has an advisory_locking structure attached,
|
||||||
@@ -1612,7 +1609,7 @@ acquire_advisory_lock(struct vnode* vnode, pid_t session, struct flock* flock,
|
|||||||
|
|
||||||
locking = vnode->advisory_locking;
|
locking = vnode->advisory_locking;
|
||||||
team_id team = team_get_current_team_id();
|
team_id team = team_get_current_team_id();
|
||||||
waitForLock = -1;
|
sem_id waitForLock = -1;
|
||||||
|
|
||||||
// test for collisions
|
// test for collisions
|
||||||
LockList::Iterator iterator = locking->locks.GetIterator();
|
LockList::Iterator iterator = locking->locks.GetIterator();
|
||||||
@@ -1654,9 +1651,7 @@ acquire_advisory_lock(struct vnode* vnode, pid_t session, struct flock* flock,
|
|||||||
struct advisory_lock* lock = (struct advisory_lock*)malloc(
|
struct advisory_lock* lock = (struct advisory_lock*)malloc(
|
||||||
sizeof(struct advisory_lock));
|
sizeof(struct advisory_lock));
|
||||||
if (lock == NULL) {
|
if (lock == NULL) {
|
||||||
if (waitForLock >= B_OK)
|
put_advisory_locking(locking);
|
||||||
release_sem_etc(waitForLock, 1, B_RELEASE_ALL);
|
|
||||||
release_sem(locking->lock);
|
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user