apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr/locks/unix proc_mutex.c
Date Mon, 14 Jun 2004 09:09:55 GMT
jorton      2004/06/14 02:09:55

  Modified:    locks/unix proc_mutex.c
  Log:
  * locks/unix/proc_mutex.c (proc_mutex_posix_cleanup): Ignore
  interproc->filedes, always close the semaphore.
  (proc_mutex_posix_create): Don't call cleanup if sem_open failed,
  don't set interproc->filedes to -1.
  (proc_mutex_posix_acquire): Simplify error handling.
  (proc_mutex_posix_release): Simplify.  Only clear curr_locked flag on
  success.
  
  Revision  Changes    Path
  1.41      +9 -19     apr/locks/unix/proc_mutex.c
  
  Index: proc_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/proc_mutex.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -d -w -u -r1.40 -r1.41
  --- proc_mutex.c	14 Jun 2004 08:53:31 -0000	1.40
  +++ proc_mutex.c	14 Jun 2004 09:09:55 -0000	1.41
  @@ -47,21 +47,18 @@
   static apr_status_t proc_mutex_posix_cleanup(void *mutex_)
   {
       apr_proc_mutex_t *mutex=mutex_;
  -    apr_status_t stat = APR_SUCCESS;
       
  -    if (mutex->interproc->filedes != -1) {
           if (sem_close(mutex->psem_interproc) < 0) {
  -            stat = errno;
  -        }
  +        return errno;
       }
  -    return stat;
  +
  +    return APR_SUCCESS;
   }    
   
   static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
                                               const char *fname)
   {
       sem_t *psem;
  -    apr_status_t stat;
       char semname[31];
       apr_time_t now;
       unsigned long sec;
  @@ -69,7 +66,6 @@
       
       new_mutex->interproc = apr_palloc(new_mutex->pool,
                                         sizeof(*new_mutex->interproc));
  -    new_mutex->interproc->filedes = -1;
       /*
        * This bogusness is to follow what appears to be the
        * lowest common denominator in Posix semaphore naming:
  @@ -107,9 +103,7 @@
       }
   
       if (psem == (sem_t *)SEM_FAILED) {
  -        stat = errno;
  -        proc_mutex_posix_cleanup(new_mutex);
  -        return stat;
  +        return errno;
       }
       /* Ahhh. The joys of Posix sems. Predelete it... */
       sem_unlink((const char *) semname);
  @@ -123,9 +117,7 @@
   
   static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex)
   {
  -    int rc;
  -
  -    if ((rc = sem_wait(mutex->psem_interproc)) < 0) {
  +    if (sem_wait(mutex->psem_interproc) < 0) {
           return errno;
       }
       mutex->curr_locked = 1;
  @@ -134,12 +126,10 @@
   
   static apr_status_t proc_mutex_posix_release(apr_proc_mutex_t *mutex)
   {
  -    int rc;
  -
  -    mutex->curr_locked = 0;
  -    if ((rc = sem_post(mutex->psem_interproc)) < 0) {
  +    if (sem_post(mutex->psem_interproc) < 0) {
           return errno;
       }
  +    mutex->curr_locked = 0;
       return APR_SUCCESS;
   }
   
  
  
  

Mime
View raw message