manoj       99/03/21 02:42:36

  Modified:    pthreads/src/main http_main.c http_protocol.c
  Log:
  Make MaxRequestsPerChild work in the threaded server again (well at
  least it works like the process server works). This consists of a few
  changes:
  
  - We need to actually count requests. In the pthreads port, we do this
    by decrementing requests_this_child
  - Send a SIGWINCH when we reach the accept_thread, to alert the rest of
    the process to its eventual demise
  - Temporarily comment out a SIG_IGN setting for SIGWINCH in
    http_protocol.c. Otherwise, sigwait() won't see reliably see a
    SIGWINCH, and the SIG_IGN isn't needed in a server with a
    signal-handling thread anyway.
  
  Revision  Changes    Path
  1.63      +12 -0     apache-apr/pthreads/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_main.c,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -u -r1.62 -r1.63
  --- http_main.c       1999/03/19 14:02:03     1.62
  +++ http_main.c       1999/03/21 10:42:34     1.63
  @@ -1804,6 +1804,7 @@
               csd = -1;
           }
           else {
  +            requests_this_child--;
               csd = accept(sd, &sa_client, &len);
            SAFE_ACCEPT(accept_mutex_off(my_tid - ap_threads_per_child));
        }
  @@ -1817,6 +1818,16 @@
            }
           } 
       }
  +
  +    /* Raise SIGWINCH so that all the actions that go with a gradual,
  +     * graceful shutdown of the process get done.
  +     *
  +     * The reason this thread is actually going through the trouble to
  +     * look up its own process ID is because under Red Hat 5.2, getpid()
  +     * actually returns the "process ID" of the thread, since threads
  +     * are just processes that share everything. I hope this is fixed in
  +     * glibc 2.1 & Linux 2.2. - mvsk */
  +    kill(ap_scoreboard_image->parent[my_pid].pid, SIGWINCH);
       ap_update_child_status(my_pid, my_tid, SERVER_DEAD, (request_rec *) 
NULL);
       return NULL;
   }
  @@ -2146,6 +2157,7 @@
   
       if (one_process) {
        set_signals();
  +        ap_scoreboard_image->parent[slot].pid = getpid();
        child_main(slot);
       }
   
  
  
  
  1.13      +7 -0      apache-apr/pthreads/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_protocol.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -u -r1.12 -r1.13
  --- http_protocol.c   1999/03/17 20:00:40     1.12
  +++ http_protocol.c   1999/03/21 10:42:34     1.13
  @@ -806,9 +806,16 @@
       }
       /* we've probably got something to do, ignore graceful restart requests 
*/
   
  +    /* XXX - sigwait doesn't work if the signal has been SIG_IGNed (under
  +     * linux 2.0 w/ glibc 2.0, anyway), and this step isn't necessary when
  +     * we're running a sigwait thread anyway. If/when unthreaded mode is put
  +     * back in, we should make sure to ignore this signal iff a sigwait 
thread
  +     * isn't used. - mvsk
  +
   #ifdef SIGWINCH
       signal(SIGWINCH, SIG_IGN);
   #endif
  +    */
   
       ap_bsetflag(conn->client, B_SAFEREAD, 0);
   
  
  
  

Reply via email to