apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/locks/unix crossproc.c
Date Fri, 31 Aug 2001 13:07:15 GMT
trawick     01/08/31 06:07:15

  Modified:    locks/unix crossproc.c
  Log:
  fix some return codes from apr lock create; we were looking at errno
  *after* calling the cleanup routine, which really sucks since the cleanup
  routine may have made a failing syscall; thus the real error wouldn't
  be reported to the user
  
  example: apr_lock_create() specifying a file which already exists
  
      old retcode: EBADF     (errno from unnecessary close() in lock cleanup)
      new retcode: EEXIST    (errno from open(O_CREATE|O_EXCL)
  
  Revision  Changes    Path
  1.53      +14 -5     apr/locks/unix/crossproc.c
  
  Index: crossproc.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/crossproc.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- crossproc.c	2001/07/23 03:28:30	1.52
  +++ crossproc.c	2001/08/31 13:07:15	1.53
  @@ -87,17 +87,20 @@
   static apr_status_t sysv_create(apr_lock_t *new, const char *fname)
   {
       union semun ick;
  +    apr_status_t stat;
       
       new->interproc = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
   
       if (new->interproc < 0) {
  +        stat = errno;
           sysv_cleanup(new);
  -        return errno;
  +        return stat;
       }
       ick.val = 1;
       if (semctl(new->interproc, 0, SETVAL, ick) < 0) {
  +        stat = errno;
           sysv_cleanup(new);
  -        return errno;
  +        return stat;
       }
       new->curr_locked = 0;
       apr_pool_cleanup_register(new->pool, (void *)new, sysv_cleanup, 
  @@ -383,8 +386,10 @@
       }
   
       if (new->interproc < 0) {
  +        apr_status_t stat = errno;
  +
           fcntl_cleanup(new);
  -        return errno;
  +        return stat;
       }
   
       new->curr_locked=0;
  @@ -492,8 +497,10 @@
       }
   
       if (new->interproc < 0) {
  +        apr_status_t stat = errno;
  +
           flock_cleanup(new);
  -        return errno;
  +        return stat;
       }
       new->curr_locked = 0;
       apr_pool_cleanup_register(new->pool, (void *)new, flock_cleanup,
  @@ -551,8 +558,10 @@
       new->fname = apr_pstrdup(cont, fname);
       new->interproc = open(new->fname, O_WRONLY, 0600);
       if (new->interproc == -1) {
  +        apr_status_t stat = errno;
  +
           flock_destroy(new);
  -        return errno;
  +        return stat;
       }
       *lock = new;
       return APR_SUCCESS;
  
  
  

Mime
View raw message