You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2002/04/01 02:32:39 UTC

cvs commit: httpd-2.0/server/mpm/perchild mpm.h perchild.c

rbb         02/03/31 16:32:39

  Modified:    server/mpm/perchild mpm.h perchild.c
  Log:
  Get the Perchild MPM to compile and serve pages again.  There are a lot
  of bugs left in this, but I am taking things one step at a time.  This
  will work again.  This also gets perchild using the correct variable for
  MaxRequestsPerChild
  
  PR:     9856, 9855, 9052
  
  Revision  Changes    Path
  1.15      +1 -0      httpd-2.0/server/mpm/perchild/mpm.h
  
  Index: mpm.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/mpm.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- mpm.h	29 Mar 2002 16:15:33 -0000	1.14
  +++ mpm.h	1 Apr 2002 00:32:39 -0000	1.15
  @@ -76,6 +76,7 @@
   #define AP_MPM_WANT_SET_MAX_REQUESTS
   #define AP_MPM_WANT_SET_COREDUMPDIR
   #define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
  +#define AP_MPM_USES_POD
   
   #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
   #define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
  
  
  
  1.118     +20 -40    httpd-2.0/server/mpm/perchild/perchild.c
  
  Index: perchild.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
  retrieving revision 1.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- perchild.c	29 Mar 2002 08:17:25 -0000	1.117
  +++ perchild.c	1 Apr 2002 00:32:39 -0000	1.118
  @@ -167,12 +167,12 @@
   static int thread_limit = DEFAULT_THREAD_LIMIT;
   static int first_thread_limit;
   static int changed_limit_at_restart;
  -static int max_requests_per_child = 0;
   static int num_daemons = 0;
   static int curr_child_num = 0;
   static int workers_may_exit = 0;
   static int requests_this_child;
  -static int num_listenfds = 0;
  +static int num_listensocks = 0;
  +static ap_pod_t *pod;
   static apr_socket_t **listenfds;
   static jmp_buf jmpbuffer;
   
  @@ -299,7 +299,7 @@
               *result = max_spare_threads;
               return APR_SUCCESS;
           case AP_MPMQ_MAX_REQUESTS_DAEMON:
  -            *result = max_requests_per_child;
  +            *result = ap_max_requests_per_child;
               return APR_SUCCESS; 
           case AP_MPMQ_MAX_DAEMONS:
               *result = num_daemons;
  @@ -654,8 +654,10 @@
       int thread_num = *((int *) arg);
       long conn_id = child_num * thread_limit + thread_num;
       apr_pollfd_t *pollset;
  -    int n;
       apr_status_t rv;
  +    ap_listen_rec *lr;
  +    int n;
  +    apr_socket_t *childsock = NULL;
   
       apr_lock_acquire(thread_pool_parent_mutex);
       apr_pool_create(&tpool, thread_pool_parent);
  @@ -666,14 +668,16 @@
                                                  SERVER_STARTING,
                                                  (request_rec *) NULL);
   
  -    apr_poll_setup(&pollset, num_listenfds+1, tpool);
  -    for(n = 0; n <= num_listenfds; ++n) {
  -        apr_poll_socket_add(pollset, listenfds[n], APR_POLLIN);
  +    apr_poll_setup(&pollset, num_listensocks + 1, tpool);
  +    for(lr = ap_listeners; lr != NULL; lr = lr->next) {
  +        apr_poll_socket_add(pollset, lr->sd, APR_POLLIN);
       }
  +    apr_os_sock_put(&childsock, &child_info_table[child_num].sd, tpool);
  +    apr_poll_socket_add(pollset, childsock, APR_POLLIN);
   
       while (!workers_may_exit) {
  -        workers_may_exit |= (max_requests_per_child != 0)
  -                            && (requests_this_child <= 0);
  +        workers_may_exit |= ((ap_max_requests_per_child != 0)
  +                            && (requests_this_child <= 0));
           if (workers_may_exit) break;
           if (!thread_just_started) {
               apr_lock_acquire(idle_thread_count_mutex);
  @@ -724,25 +728,24 @@
               }
               if (workers_may_exit) break;
   
  -            apr_poll_revents_get(&event, listenfds[0], pollset);
  +/*            apr_poll_revents_get(&event, listenfds[0], pollset);
               if (event & APR_POLLIN) {
                   /* A process got a signal on the shutdown pipe. Check if we're
  -                 * the lucky process to die. */
  +                 * the lucky process to die. 
                   check_pipe_of_death();
                   continue;
               }
  -            
               apr_poll_revents_get(&event, listenfds[1], pollset);
               if (event & APR_POLLIN || event & APR_POLLOUT) {
                   /* This request is from another child in our current process.
                    * We should set a flag here, and then below we will read
                    * two bytes (the socket number and the NULL byte.
  -                 */
                   thread_socket_table[thread_num] = AP_PERCHILD_OTHERCHILD;
                   goto got_from_other_child;
               }
  +           */ 
   
  -            if (num_listenfds == 1) {
  +            if (num_listensocks == 1) {
                   sd = ap_listeners->sd;
                   goto got_fd;
               }
  @@ -751,7 +754,7 @@
                   curr_pollfd = last_pollfd;
                   do {
                       curr_pollfd++;
  -                    if (curr_pollfd > num_listenfds) {
  +                    if (curr_pollfd > num_listensocks) {
                           curr_pollfd = 1;
                       }
                       /* XXX: Should we check for POLLERR? */
  @@ -951,7 +954,6 @@
   static void child_main(int child_num_arg)
   {
       int i;
  -    ap_listen_rec *lr;
       apr_status_t rv;
   
       my_pid = getpid();
  @@ -978,23 +980,8 @@
   
       apr_setup_signal_thread();
   
  -    requests_this_child = max_requests_per_child;
  +    requests_this_child = ap_max_requests_per_child;
       
  -    /* Set up the pollfd array, num_listenfds + 1 for the pipe and 1 for
  -     * the child socket.
  -     */
  -    listenfds = apr_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 2));
  -#if APR_FILES_AS_SOCKETS
  -    apr_socket_from_file(&listenfds[0], pipe_of_death_in);
  -#endif
  -
  -    /* The child socket */
  -    apr_os_sock_put(&listenfds[1], &child_info_table[child_num].sd, pchild);
  -
  -    num_listenfds++;
  -    for (lr = ap_listeners, i = 2; i <= num_listenfds; lr = lr->next, ++i) {
  -        listenfds[i]=lr->sd;
  -    }
   
       /* Setup worker threads */
   
  @@ -1279,13 +1266,6 @@
           exit(1);
       }
       ap_server_conf = s;
  -    if ((num_listenfds = ap_setup_listeners(ap_server_conf)) < 1) {
  -        /* XXX: hey, what's the right way for the mpm to indicate
  -         * a fatal error? */
  -        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
  -                     "no listening sockets available, shutting down");
  -        return 1;
  -    }
   
       /* Initialize cross-process accept lock */
       ap_lock_fname = apr_psprintf(_pconf, "%s.%u",
  @@ -1496,7 +1476,7 @@
       max_threads = thread_limit;
       ap_pid_fname = DEFAULT_PIDLOG;
       ap_lock_fname = DEFAULT_LOCKFILE;
  -    max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
  +    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
       curr_child_num = 0;
   
       apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));