manoj       99/08/13 12:47:02

  Modified:    mpm/src/modules/mpm/dexter dexter.c
  Log:
  Get rid of the single-child worker thread implementation for now. It's a
  pain keeping track of them both, and it can be added back easily..
  
  Revision  Changes    Path
  1.23      +1 -133    apache-2.0/mpm/src/modules/mpm/dexter/dexter.c
  
  Index: dexter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -d -u -r1.22 -r1.23
  --- dexter.c  1999/08/13 06:57:46     1.22
  +++ dexter.c  1999/08/13 19:47:01     1.23
  @@ -893,23 +893,15 @@
   }
   
   static void *worker_thread(void *);
  -static void *worker_thread_one_child(void *);
   
   /* Starts a thread as long as we're below max_threads */
   static int start_thread(void)
   {
       pthread_t thread;
  -    void *(*thread_function)(void *);
   
       pthread_mutex_lock(&worker_thread_count_mutex);
       if (worker_thread_count < max_threads) {
  -        if (num_daemons == 1) {
  -            thread_function = worker_thread_one_child;
  -        }
  -        else {
  -            thread_function = worker_thread;
  -        }
  -        if (pthread_create(&thread, &worker_thread_attr, thread_function,
  +        if (pthread_create(&thread, &worker_thread_attr, worker_thread,
          &worker_thread_free_ids[worker_thread_count])) {
               ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf,
                            "pthread_create: unable to create worker thread");
  @@ -964,130 +956,6 @@
   }
   
   /* idle_thread_count should be incremented before starting a worker_thread */
  -
  -static void *worker_thread_one_child(void *arg)
  -{
  -    struct sockaddr sa_client;
  -    int csd = -1;
  -    pool *tpool;                /* Pool for this thread           */
  -    pool *ptrans;                /* Pool for per-transaction stuff */
  -    int sd = -1;
  -    int srv;
  -    int poll_count = 0;
  -    static int curr_pollfd = 0;
  -    size_t len = sizeof(struct sockaddr);
  -    int thread_just_started = 1;
  -    int thread_num = *((int *) arg);
  -    long conn_id = child_num * HARD_THREAD_LIMIT + thread_num;
  -
  -    pthread_mutex_lock(&thread_pool_create_mutex);
  -    tpool = ap_make_sub_pool(thread_pool_parent);
  -    pthread_mutex_unlock(&thread_pool_create_mutex);
  -    ptrans = ap_make_sub_pool(tpool);
  -
  -    while (!workers_may_exit) {
  -        workers_may_exit |= (max_requests_per_child != 0) && 
(requests_this_child <= 0);
  -        if (workers_may_exit) break;
  -        if (!thread_just_started) {
  -            pthread_mutex_lock(&idle_thread_count_mutex);
  -            if (idle_thread_count < max_spare_threads) {
  -                idle_thread_count++;
  -                pthread_mutex_unlock(&idle_thread_count_mutex);
  -            }
  -            else {
  -                pthread_mutex_unlock(&idle_thread_count_mutex);
  -                break;
  -            }
  -        }
  -        else {
  -            thread_just_started = 0;
  -        }
  -        SAFE_ACCEPT(intra_mutex_on(0));
  -        while (!workers_may_exit) {
  -            if (poll_count > 0) {
  -                /* Just check the pipe_of_death */
  -                srv = poll(listenfds, 1, 0);
  -            } else {
  -                srv = poll_count = poll(listenfds, num_listenfds + 1, -1);
  -                curr_pollfd = 0;
  -            }
  -            if (srv < 0) {
  -                if (errno == EINTR) {
  -                    continue;
  -                }
  -
  -                /* poll() will only return errors in catastrophic
  -                 * circumstances. Let's try exiting gracefully, for now. */
  -                ap_log_error(APLOG_MARK, APLOG_ERR, (const server_rec *)
  -                             ap_get_server_conf(), "poll: (listen)");
  -                workers_may_exit = 1;
  -            }
  -            if (workers_may_exit) break;
  -
  -            if (listenfds[0].revents & POLLIN) {
  -                /* A process got a signal on the shutdown pipe. Check if
  -                 * we're the lucky process to die. */
  -                check_pipe_of_death();
  -                continue;
  -            }
  -
  -            if (num_listenfds == 1) {
  -                sd = ap_listeners->fd;
  -                poll_count = 0;
  -                goto got_fd;
  -            }
  -            else {
  -                /* find a listener. */
  -                for(;;) {
  -                    curr_pollfd++;
  -                    /* XXX: Should we check for POLLERR? */
  -                    if (listenfds[curr_pollfd].revents & POLLIN) {
  -                        poll_count--;
  -                        sd = listenfds[curr_pollfd].fd;
  -                        goto got_fd;
  -                    }
  -                }
  -            }
  -        }
  -    got_fd:
  -        if (!workers_may_exit) {
  -            csd = ap_accept(sd, &sa_client, &len);
  -            SAFE_ACCEPT(intra_mutex_off(0));
  -            pthread_mutex_lock(&idle_thread_count_mutex);
  -            if (idle_thread_count > min_spare_threads) {
  -                idle_thread_count--;
  -            }
  -            else {
  -                if (!start_thread()) {
  -                    idle_thread_count--;
  -                }
  -            }
  -            pthread_mutex_unlock(&idle_thread_count_mutex);
  -        } else {
  -            SAFE_ACCEPT(intra_mutex_off(0));
  -            pthread_mutex_lock(&idle_thread_count_mutex);
  -            idle_thread_count--;
  -            pthread_mutex_unlock(&idle_thread_count_mutex);
  -            break;
  -        }
  -        process_socket(ptrans, &sa_client, csd, conn_id);
  -        ap_clear_pool(ptrans);
  -        requests_this_child--;
  -    }
  -
  -    ap_destroy_pool(tpool);
  -    pthread_mutex_lock(&worker_thread_count_mutex);
  -    worker_thread_count--;
  -    worker_thread_free_ids[worker_thread_count] = thread_num;
  -    if (worker_thread_count == 0) {
  -        /* All the threads have exited, now finish the shutdown process
  -         * by signalling the sigwait thread */
  -        kill(my_pid, SIGTERM);
  -    }
  -    pthread_mutex_unlock(&worker_thread_count_mutex);
  -
  -    return NULL;
  -}
   
   static void *worker_thread(void *arg)
   {
  
  
  

Reply via email to