manoj       99/04/08 20:15:40

  Modified:    pthreads/src/main acceptlock.c
  Log:
  Fix acceptlock bugs found during warning scrubbing. expand_lock_fname is
  now static. Also, the psprintf in that function had an extra argument
  (the parent process pid), which wasn't used, and can't be used in child
  processes, but which is useful.
  
  So, we use it by create a new init_lock_fname which is used only
  in the parent process so that the getpid() call returns the expected
  result.
  
  Revision  Changes    Path
  1.3       +10 -5     apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- acceptlock.c      1999/03/07 00:47:49     1.2
  +++ acceptlock.c      1999/04/09 03:15:40     1.3
  @@ -81,14 +81,17 @@
   
   
   #if defined(USE_FCNTL_SERIALIZED_ACCEPT) || 
defined(USE_FLOCK_SERIALIZED_ACCEPT)
  -char * expand_lock_fname(pool *p, int i)
  +static void init_lock_fname(pool *p)
   {
  -    char *fname; 
       /* XXXX possibly bogus cast */
  -    fname = ap_psprintf(p, "%s.%d",
  -     ap_server_root_relative(p, ap_lock_fname), i, (unsigned long)getpid());
  -    return fname;
  +    ap_lock_fname = ap_psprintf(p, "%s.%lu",
  +        ap_server_root_relative(p, ap_lock_fname), (unsigned long)getpid());
   }
  +
  +static char * expand_lock_fname(pool *p, int i)
  +{
  +    return ap_psprintf(p, "%s.%d", ap_lock_fname, i);
  +}
   #endif
   
   #if defined (USE_USLOCK_SERIALIZED_ACCEPT)
  @@ -423,6 +426,7 @@
       unlock_it.l_type = F_UNLCK;              /* set exclusive/write lock */
       unlock_it.l_pid = 0;             /* pid not actually interesting */
   
  +    init_lock_fname(p);
       for (i = 0; i < ap_acceptors_per_child; i++) {
           lock_fname = expand_lock_fname(p, i);
        lock_fd[i] = ap_popenf(p, lock_fname, 
  @@ -517,6 +521,7 @@
       char *lock_fname;
       lock_fd = (int *)ap_palloc(p, ap_acceptors_per_child * sizeof(int *));
     
  +    init_lock_fname(p);
       for (i = 0; i < ap_acceptors_per_child; i++) {
           lock_fname = expand_lock_fname(p, i);
           unlink(lock_fname);
  
  
  

Reply via email to