apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/threadproc/beos thread.c
Date Sun, 31 Dec 2000 18:48:04 GMT
dreid       00/12/31 10:48:04

  Modified:    include/arch/beos locks.h
               locks/beos crossproc.c intraproc.c locks.c
               threadproc/beos thread.c
  Log:
  Various bits of tidying up mainly for locking, but a few thread bits as well.
  
  Submitted by:	Carlos Hasan <chasan@acm.org>
  Reviewed by:	David Reid   <dreid@apache.org>
  
  Revision  Changes    Path
  1.10      +1 -3      apr/include/arch/beos/locks.h
  
  Index: locks.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/beos/locks.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- locks.h	2000/08/02 05:26:19	1.9
  +++ locks.h	2000/12/31 18:48:02	1.10
  @@ -65,9 +65,7 @@
       apr_pool_t *cntxt;
       apr_locktype_e type;
       apr_lockscope_e scope;
  -    int curr_locked;
  -    char *fname;
  -	/* Inter proc */
  +    /* Inter proc */
       sem_id sem_interproc;
       int32  ben_interproc;
       /* Intra Proc */
  
  
  
  1.18      +9 -10     apr/locks/beos/crossproc.c
  
  Index: crossproc.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/crossproc.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- crossproc.c	2000/11/09 06:25:28	1.17
  +++ crossproc.c	2000/12/31 18:48:02	1.18
  @@ -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 @@
   {
       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 @@
       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 @@
       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;
   }
   
  
  
  
  1.14      +5 -13     apr/locks/beos/intraproc.c
  
  Index: intraproc.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/intraproc.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- intraproc.c	2000/11/09 06:25:28	1.13
  +++ intraproc.c	2000/12/31 18:48:03	1.14
  @@ -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 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 @@
       }
       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 @@
       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 @@
       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;
   }
   
  
  
  
  1.23      +0 -1      apr/locks/beos/locks.c
  
  Index: locks.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/locks.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- locks.c	2000/11/19 01:05:15	1.22
  +++ locks.c	2000/12/31 18:48:03	1.23
  @@ -71,7 +71,6 @@
       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) {
  
  
  
  1.16      +0 -7      apr/threadproc/beos/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/thread.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- thread.c	2000/11/19 01:05:16	1.15
  +++ thread.c	2000/12/31 18:48:03	1.16
  @@ -58,8 +58,6 @@
   {
       (*new) = (apr_threadattr_t *)apr_palloc(cont, 
                 sizeof(apr_threadattr_t));
  -    (*new)->attr = (int32)apr_palloc(cont, 
  -                    sizeof(int32));
   
       if ((*new) == NULL) {
           return APR_ENOMEM;
  @@ -98,11 +96,6 @@
       
       (*new) = (apr_thread_t *)apr_palloc(cont, sizeof(apr_thread_t));
       if ((*new) == NULL) {
  -        return APR_ENOMEM;
  -    }
  -
  -	(*new)->td = (thread_id) apr_palloc(cont, sizeof(thread_id));
  -    if ((*new)->td == (thread_id)NULL) {
           return APR_ENOMEM;
       }
   
  
  
  

Mime
View raw message