summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
Diffstat (limited to 'locks')
-rw-r--r--locks/beos/crossproc.c19
-rw-r--r--locks/beos/intraproc.c18
-rw-r--r--locks/beos/locks.c1
3 files changed, 14 insertions, 24 deletions
diff --git a/locks/beos/crossproc.c b/locks/beos/crossproc.c
index 02e9bd76e..b17aa28f3 100644
--- a/locks/beos/crossproc.c
+++ b/locks/beos/crossproc.c
@@ -57,8 +57,13 @@
apr_status_t lock_inter_cleanup(void * data)
{
apr_lock_t *lock = (apr_lock_t*)data;
- if (lock->curr_locked == 1) {
- if (atomic_add(&lock->ben_interproc , -1) > 1){
+ if (lock->ben_interproc != 0) {
+ /* we're still locked... */
+ while (atomic_add(&lock->ben_interproc , -1) > 1){
+ /* OK we had more than one person waiting on the lock so
+ * the sem is also locked. Release it until we have no more
+ * locks left.
+ */
release_sem (lock->sem_interproc);
}
}
@@ -70,15 +75,11 @@ apr_status_t create_inter_lock(apr_lock_t *new)
{
int32 stat;
- new->sem_interproc = (sem_id)apr_palloc(new->cntxt, sizeof(sem_id));
- new->ben_interproc = (int32)apr_palloc(new->cntxt, sizeof(int32));
-
if ((stat = create_sem(0, "apr_interproc")) < B_NO_ERROR) {
lock_inter_cleanup(new);
return stat;
}
new->ben_interproc = 0;
- new->curr_locked = 0;
new->sem_interproc = stat;
apr_register_cleanup(new->cntxt, (void *)new, lock_inter_cleanup,
apr_null_cleanup);
@@ -90,12 +91,11 @@ apr_status_t lock_inter(apr_lock_t *lock)
int32 stat;
if (atomic_add(&lock->ben_interproc, 1) > 0){
- if ((stat = acquire_sem(lock->sem_interproc)) != B_NO_ERROR){
+ if ((stat = acquire_sem(lock->sem_interproc)) < B_NO_ERROR){
atomic_add(&lock->ben_interproc, -1);
return stat;
}
}
- lock->curr_locked = 1;
return APR_SUCCESS;
}
@@ -104,12 +104,11 @@ apr_status_t unlock_inter(apr_lock_t *lock)
int32 stat;
if (atomic_add(&lock->ben_interproc, -1) > 1){
- if ((stat = release_sem(lock->sem_interproc)) != B_NO_ERROR) {
+ if ((stat = release_sem(lock->sem_interproc)) < B_NO_ERROR) {
atomic_add(&lock->ben_interproc, 1);
return stat;
}
}
- lock->curr_locked = 0;
return APR_SUCCESS;
}
diff --git a/locks/beos/intraproc.c b/locks/beos/intraproc.c
index 10537de08..65cb5a3e5 100644
--- a/locks/beos/intraproc.c
+++ b/locks/beos/intraproc.c
@@ -57,11 +57,9 @@
apr_status_t lock_intra_cleanup(void *data)
{
apr_lock_t *lock = (apr_lock_t *)data;
- if (lock->curr_locked == 1) {
- if (atomic_add(&lock->ben_intraproc , -1) > 1){
+ if (lock->ben_intraproc != 0) {
+ while (atomic_add(&lock->ben_intraproc , -1) > 1){
release_sem (lock->sem_intraproc);
- } else {
- return errno;
}
}
delete_sem(lock->sem_intraproc);
@@ -70,10 +68,7 @@ apr_status_t lock_intra_cleanup(void *data)
apr_status_t create_intra_lock(apr_lock_t *new)
{
- int32 stat;
- new->sem_intraproc = (sem_id)apr_palloc(new->cntxt, sizeof(sem_id));
- new->ben_intraproc = (int32)apr_palloc(new->cntxt, sizeof(int32));
-
+ int32 stat;
if ((stat = create_sem(0, "apr_intraproc")) < B_NO_ERROR){
lock_intra_cleanup(new);
@@ -81,7 +76,6 @@ apr_status_t create_intra_lock(apr_lock_t *new)
}
new->ben_intraproc = 0;
new->sem_intraproc = stat;
- new->curr_locked = 0;
apr_register_cleanup(new->cntxt, (void *)new, lock_intra_cleanup,
apr_null_cleanup);
return APR_SUCCESS;
@@ -92,12 +86,11 @@ apr_status_t lock_intra(apr_lock_t *lock)
int32 stat;
if (atomic_add (&lock->ben_intraproc, 1) > 0){
- if ((stat = acquire_sem(lock->sem_intraproc)) != B_NO_ERROR){
+ if ((stat = acquire_sem(lock->sem_intraproc)) < B_NO_ERROR){
atomic_add(&lock->ben_intraproc,-1);
return stat;
}
}
- lock->curr_locked = 1;
return APR_SUCCESS;
}
@@ -106,12 +99,11 @@ apr_status_t unlock_intra(apr_lock_t *lock)
int32 stat;
if (atomic_add(&lock->ben_intraproc, -1) > 1){
- if ((stat = release_sem(lock->sem_intraproc)) != B_NO_ERROR) {
+ if ((stat = release_sem(lock->sem_intraproc)) < B_NO_ERROR) {
atomic_add(&lock->ben_intraproc, 1);
return stat;
}
}
- lock->curr_locked = 0;
return APR_SUCCESS;
}
diff --git a/locks/beos/locks.c b/locks/beos/locks.c
index 818201136..5302a1b59 100644
--- a/locks/beos/locks.c
+++ b/locks/beos/locks.c
@@ -71,7 +71,6 @@ apr_status_t apr_create_lock(apr_lock_t **lock, apr_locktype_e type,
new->cntxt = cont;
new->type = type;
new->scope = scope;
- new->fname = apr_pstrdup(cont, fname);
if (scope != APR_CROSS_PROCESS) {
if ((stat = create_intra_lock(new)) != APR_SUCCESS) {