You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by bj...@hyperreal.org on 1999/07/12 10:35:40 UTC

cvs commit: apache-2.0/mpm/src/modules/mpm/spmt_os2 spmt_os2.c

bjh         99/07/12 01:35:39

  Modified:    mpm/src/modules/mpm/spmt_os2 spmt_os2.c
  Log:
  Assorted fixes for the OS/2 mpm:
  - pchild really should be thread local
  - clean_child_exit() should call _endthread(), not exit()
  - Use DosSleep() for delay in wait_or_timeout() instead of ap_select
  - Rework logic of searching for listen rec in child main, was getting hung
    in infinite loop when two sockets were being listened to. NOTE: I got it
    from prefork.c originally so that's probably broken too.
  - Remove a debugging fprintf I accidentally left in...
  
  Revision  Changes    Path
  1.2       +25 -24    apache-2.0/mpm/src/modules/mpm/spmt_os2/spmt_os2.c
  
  Index: spmt_os2.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/spmt_os2/spmt_os2.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- spmt_os2.c	1999/07/11 14:49:06	1.1
  +++ spmt_os2.c	1999/07/12 08:35:39	1.2
  @@ -151,12 +151,12 @@
   #endif
   
   static pool *pconf;		/* Pool for config stuff */
  -static pool *pchild;		/* Pool for httpd child stuff */
   static int my_pid;	/* it seems silly to call getpid all the time */
   static scoreboard *ap_scoreboard_image = NULL;
   static int volatile exit_after_unblock = 0;
   
   struct thread_globals {
  +    pool *pchild;		/* Pool for httpd child stuff */
       int srv;
       int csd;
       int requests_this_child;
  @@ -188,13 +188,12 @@
   
   
   /* a clean exit from a child with proper cleanup */
  -static void clean_child_exit(int code) __attribute__ ((noreturn));
   static void clean_child_exit(int code)
   {
  -    if (pchild) {
  -	ap_destroy_pool(pchild);
  +    if (THREAD_GLOBAL(pchild)) {
  +	ap_destroy_pool(THREAD_GLOBAL(pchild));
       }
  -    exit(code);
  +    _endthread();
   }
   
   
  @@ -232,7 +231,7 @@
   static void accept_mutex_init(pool *p)
   {
       int rc = DosCreateMutexSem(NULL, &lock_sem, DC_SEM_SHARED, FALSE);
  -fprintf(stderr, "Created mutex\n");
  +    
       if (rc != 0) {
   	ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf,
   		    "Parent cannot create lock semaphore, rc=%d", rc);
  @@ -532,7 +531,6 @@
   
   static int wait_or_timeout(ap_wait_t *status)
   {
  -    struct timeval tv;
       int ret;
   
       ++wait_or_timeout_counter;
  @@ -549,9 +547,8 @@
       if (ret > 0) {
   	return ret;
       }
  -    tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
  -    tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
  -    ap_select(0, NULL, NULL, NULL, &tv);
  +    
  +    DosSleep(SCOREBOARD_MAINTENANCE_INTERVAL / 1000);
       return -1;
   }
   
  @@ -905,15 +902,15 @@
       NET_SIZE_T clen;
       struct sockaddr sa_server;
       struct sockaddr sa_client;
  -    ap_listen_rec *lr;
  -    ap_listen_rec *last_lr;
  +    ap_listen_rec *lr = NULL;
  +    ap_listen_rec *first_lr = NULL;
       pool *ptrans;
       conn_rec *current_conn;
       int my_child_num = (int)child_num_arg;
       ap_iol *iol;
  +    pool *pchild;
   
       my_pid = getpid();
  -    last_lr = NULL;
   
       /* Disable the restart signal handlers and enable the just_die stuff.
        * Note that since restart() just notes that a restart has been
  @@ -928,6 +925,7 @@
        */
       pchild = ap_make_sub_pool(pconf);
       *ppthread_globals = (struct thread_globals *)ap_palloc(pchild, sizeof(struct thread_globals));
  +    THREAD_GLOBAL(pchild) = pchild;
       THREAD_GLOBAL(ap_my_generation) = 0;
       THREAD_GLOBAL(requests_this_child) = 0;
       THREAD_GLOBAL(csd) = -1;
  @@ -997,23 +995,27 @@
   
   		/* we remember the last_lr we searched last time around so that
   		   we don't end up starving any particular listening socket */
  -		if (last_lr == NULL) {
  -		    lr = ap_listeners;
  +		if (first_lr == NULL) {
  +		    first_lr = ap_listeners;
   		}
  -		else {
  -		    lr = last_lr->next;
  -		}
  -		while (lr != last_lr) {
  +		
  +                lr = first_lr;
  +		
  +		do {
   		    if (!lr) {
   			lr = ap_listeners;
  +		    }
  +		    
  +		    if (FD_ISSET(lr->fd, &THREAD_GLOBAL(main_fds))) {
  +                        first_lr = lr->next;
  +		        break;
   		    }
  -		    if (FD_ISSET(lr->fd, &THREAD_GLOBAL(main_fds))) break;
   		    lr = lr->next;
  -		}
  -		if (lr == last_lr) {
  +		} while (lr != first_lr);
  +		
  +		if (lr == first_lr) {
   		    continue;
   		}
  -		last_lr = lr;
   		sd = lr->fd;
   	    }
   	    else {
  @@ -1181,7 +1183,6 @@
       }
   
       ap_update_child_status(slot, SERVER_STARTING, (request_rec *) NULL);
  -fprintf(stderr, "Starting thread %d\n", slot);
   
       if ((tid = _beginthread(child_main, NULL, 65536, (void *)slot)) == -1) {
   	ap_log_error(APLOG_MARK, APLOG_ERR, s, "_beginthread: Unable to create new thread");