httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/mpm/prefork prefork.c
Date Tue, 04 Apr 2000 22:37:01 GMT
rbb         00/04/04 15:37:00

  Modified:    src/lib/apr/misc/unix otherchild.c
               src/modules/mpm/dexter dexter.c
               src/modules/mpm/mpmt_pthread mpmt_pthread.c
               src/modules/mpm/prefork prefork.c
  Log:
  The Unix MPM's now use the other_child logic from APR.
  
  Revision  Changes    Path
  1.4       +1 -1      apache-2.0/src/lib/apr/misc/unix/otherchild.c
  
  Index: otherchild.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/otherchild.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- otherchild.c	2000/04/04 21:48:56	1.3
  +++ otherchild.c	2000/04/04 22:36:59	1.4
  @@ -187,7 +187,7 @@
    *    Loop through all registered other_children and call the
    *    appropriate maintenance function when necessary.
    */
  -API_EXPORT(void) check_other_child(void)
  +API_EXPORT(void) ap_check_other_child(void)
   {
       ap_other_child_rec_t *ocr, *nocr;
       pid_t waitret;    
  
  
  
  1.67      +1 -149    apache-2.0/src/modules/mpm/dexter/dexter.c
  
  Index: dexter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/dexter.c,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- dexter.c	2000/03/31 09:05:04	1.66
  +++ dexter.c	2000/04/04 22:36:59	1.67
  @@ -141,19 +141,6 @@
   int raise_sigstop_flags;
   #endif
   
  -#ifdef HAS_OTHER_CHILD
  -/* used to maintain list of children which aren't part of the child table */
  -typedef struct other_child_rec other_child_rec;
  -struct other_child_rec {
  -    other_child_rec *next;
  -    int pid;
  -    void (*maintenance) (int, void *, ap_wait_t);
  -    void *data;
  -    int write_fd;
  -};
  -static other_child_rec *other_children;
  -#endif
  -
   static ap_context_t *pconf;		/* Pool for config stuff */
   static ap_context_t *pchild;		/* Pool for httpd child stuff */
   static ap_context_t *thread_pool_parent; /* Parent of per-thread pools */
  @@ -199,117 +186,6 @@
       exit(code);
   }
   
  -/*****************************************************************
  - * dealing with other children
  - */
  -
  -#ifdef HAS_OTHER_CHILD
  -API_EXPORT(void) ap_register_other_child(int pid,
  -		       void (*maintenance) (int reason, void *, ap_wait_t status),
  -			  void *data, int write_fd)
  -{
  -    other_child_rec *ocr;
  -
  -    ocr = ap_palloc(pconf, sizeof(*ocr));
  -    ocr->pid = pid;
  -    ocr->maintenance = maintenance;
  -    ocr->data = data;
  -    ocr->write_fd = write_fd;
  -    ocr->next = other_children;
  -    other_children = ocr;
  -}
  -
  -/* note that since this can be called by a maintenance function while we're
  - * scanning the other_children list, all scanners should protect themself
  - * by loading ocr->next before calling any maintenance function.
  - */
  -API_EXPORT(void) ap_unregister_other_child(void *data)
  -{
  -    other_child_rec **pocr, *nocr;
  -
  -    for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
  -	if ((*pocr)->data == data) {
  -	    nocr = (*pocr)->next;
  -	    (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
  -	    *pocr = nocr;
  -	    /* XXX: um, well we've just wasted some space in pconf ? */
  -	    return;
  -	}
  -    }
  -}
  -
  -/* test to ensure that the write_fds are all still writable, otherwise
  - * invoke the maintenance functions as appropriate */
  -static void probe_writable_fds(void)
  -{
  -    return;
  -#if 0
  -    fd_set writable_fds;
  -    int fd_max;
  -    other_child_rec *ocr, *nocr;
  -    struct timeval tv;
  -    int rc;
  -
  -    if (other_children == NULL)
  -	return;
  -
  -    fd_max = 0;
  -    FD_ZERO(&writable_fds);
  -    do {
  -	for (ocr = other_children; ocr; ocr = ocr->next) {
  -	    if (ocr->write_fd == -1)
  -		continue;
  -	    FD_SET(ocr->write_fd, &writable_fds);
  -	    if (ocr->write_fd > fd_max) {
  -		fd_max = ocr->write_fd;
  -	    }
  -	}
  -	if (fd_max == 0)
  -	    return;
  -
  -	tv.tv_sec = 0;
  -	tv.tv_usec = 0;
  -	rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
  -    } while (rc == -1 && errno == EINTR);
  -
  -    if (rc == -1) {
  -	/* XXX: uhh this could be really bad, we could have a bad file
  -	 * descriptor due to a bug in one of the maintenance routines */
  -	ap_log_unixerr("probe_writable_fds", "select",
  -		    "could not probe writable fds", server_conf);
  -	return;
  -    }
  -    if (rc == 0)
  -	return;
  -
  -    for (ocr = other_children; ocr; ocr = nocr) {
  -	nocr = ocr->next;
  -	if (ocr->write_fd == -1)
  -	    continue;
  -	if (FD_ISSET(ocr->write_fd, &writable_fds))
  -	    continue;
  -	(*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
  -    }
  -#endif
  -}
  -
  -/* possibly reap an other_child, return 0 if yes, -1 if not */
  -static int reap_other_child(int pid, ap_wait_t status)
  -{
  -    other_child_rec *ocr, *nocr;
  -
  -    for (ocr = other_children; ocr; ocr = nocr) {
  -	nocr = ocr->next;
  -	if (ocr->pid != pid)
  -	    continue;
  -	ocr->pid = -1;
  -	(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  -	return 0;
  -    }
  -    return -1;
  -}
  -#endif
  -
   static void reclaim_child_processes(int terminate)
   {
       int i, status;
  @@ -317,9 +193,6 @@
       struct timeval tv;
       int waitret, tries;
       int not_dead_yet;
  -#ifdef HAS_OTHER_CHILD
  -    other_child_rec *ocr, *nocr;
  -#endif
   
       for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
   	/* don't want to hold up progress any more than 
  @@ -383,29 +256,8 @@
   			    "attempting to continue anyway", pid);
   		break;
   	    }
  -	}
  -#ifdef HAS_OTHER_CHILD
  -	for (ocr = other_children; ocr; ocr = nocr) {
  -	    nocr = ocr->next;
  -	    if (ocr->pid == -1)
  -		continue;
  -
  -	    waitret = waitpid(ocr->pid, &status, WNOHANG);
  -	    if (waitret == ocr->pid) {
  -		ocr->pid = -1;
  -		(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  -	    }
  -	    else if (waitret == 0) {
  -		(*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
  -		++not_dead_yet;
  -	    }
  -	    else if (waitret == -1) {
  -		/* uh what the heck? they didn't call unregister? */
  -		ocr->pid = -1;
  -		(*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
  -	    }
   	}
  -#endif
  +        ap_check_other_child();
   	if (!not_dead_yet) {
   	    /* nothing left to wait for */
   	    break;
  
  
  
  1.60      +1 -149    apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c
  
  Index: mpmt_pthread.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- mpmt_pthread.c	2000/03/31 09:05:09	1.59
  +++ mpmt_pthread.c	2000/04/04 22:37:00	1.60
  @@ -138,19 +138,6 @@
   int raise_sigstop_flags;
   #endif
   
  -#ifdef HAS_OTHER_CHILD
  -/* used to maintain list of children which aren't part of the scoreboard */
  -typedef struct other_child_rec other_child_rec;
  -struct other_child_rec {
  -    other_child_rec *next;
  -    int pid;
  -    void (*maintenance) (int, void *, ap_wait_t);
  -    void *data;
  -    int write_fd;
  -};
  -static other_child_rec *other_children;
  -#endif
  -
   static ap_context_t *pconf;		/* Pool for config stuff */
   static ap_context_t *pchild;		/* Pool for httpd child stuff */
   
  @@ -195,117 +182,6 @@
       exit(code);
   }
   
  -/*****************************************************************
  - * dealing with other children
  - */
  -
  -#ifdef HAS_OTHER_CHILD
  -API_EXPORT(void) ap_register_other_child(int pid,
  -		       void (*maintenance) (int reason, void *, ap_wait_t status),
  -			  void *data, int write_fd)
  -{
  -    other_child_rec *ocr;
  -
  -    ocr = ap_palloc(pconf, sizeof(*ocr));
  -    ocr->pid = pid;
  -    ocr->maintenance = maintenance;
  -    ocr->data = data;
  -    ocr->write_fd = write_fd;
  -    ocr->next = other_children;
  -    other_children = ocr;
  -}
  -
  -/* note that since this can be called by a maintenance function while we're
  - * scanning the other_children list, all scanners should protect themself
  - * by loading ocr->next before calling any maintenance function.
  - */
  -API_EXPORT(void) ap_unregister_other_child(void *data)
  -{
  -    other_child_rec **pocr, *nocr;
  -
  -    for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
  -	if ((*pocr)->data == data) {
  -	    nocr = (*pocr)->next;
  -	    (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
  -	    *pocr = nocr;
  -	    /* XXX: um, well we've just wasted some space in pconf ? */
  -	    return;
  -	}
  -    }
  -}
  -
  -/* test to ensure that the write_fds are all still writable, otherwise
  - * invoke the maintenance functions as appropriate */
  -static void probe_writable_fds(void)
  -{
  -    return;
  -#if 0
  -    fd_set writable_fds;
  -    int fd_max;
  -    other_child_rec *ocr, *nocr;
  -    struct timeval tv;
  -    int rc;
  -
  -    if (other_children == NULL)
  -	return;
  -
  -    fd_max = 0;
  -    FD_ZERO(&writable_fds);
  -    do {
  -	for (ocr = other_children; ocr; ocr = ocr->next) {
  -	    if (ocr->write_fd == -1)
  -		continue;
  -	    FD_SET(ocr->write_fd, &writable_fds);
  -	    if (ocr->write_fd > fd_max) {
  -		fd_max = ocr->write_fd;
  -	    }
  -	}
  -	if (fd_max == 0)
  -	    return;
  -
  -	tv.tv_sec = 0;
  -	tv.tv_usec = 0;
  -	rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
  -    } while (rc == -1 && errno == EINTR);
  -
  -    if (rc == -1) {
  -	/* XXX: uhh this could be really bad, we could have a bad file
  -	 * descriptor due to a bug in one of the maintenance routines */
  -	ap_log_unixerr("probe_writable_fds", "select",
  -		    "could not probe writable fds", server_conf);
  -	return;
  -    }
  -    if (rc == 0)
  -	return;
  -
  -    for (ocr = other_children; ocr; ocr = nocr) {
  -	nocr = ocr->next;
  -	if (ocr->write_fd == -1)
  -	    continue;
  -	if (FD_ISSET(ocr->write_fd, &writable_fds))
  -	    continue;
  -	(*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
  -    }
  -#endif
  -}
  -
  -/* possibly reap an other_child, return 0 if yes, -1 if not */
  -static int reap_other_child(int pid, ap_wait_t status)
  -{
  -    other_child_rec *ocr, *nocr;
  -
  -    for (ocr = other_children; ocr; ocr = nocr) {
  -	nocr = ocr->next;
  -	if (ocr->pid != pid)
  -	    continue;
  -	ocr->pid = -1;
  -	(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  -	return 0;
  -    }
  -    return -1;
  -}
  -#endif
  -
   static void reclaim_child_processes(int terminate)
   {
       int i, status;
  @@ -313,9 +189,6 @@
       struct timeval tv;
       int waitret, tries;
       int not_dead_yet;
  -#ifdef HAS_OTHER_CHILD
  -    other_child_rec *ocr, *nocr;
  -#endif
   
       ap_sync_scoreboard_image();
   
  @@ -377,29 +250,8 @@
   			    "attempting to continue anyway", pid);
   		break;
   	    }
  -	}
  -#ifdef HAS_OTHER_CHILD
  -	for (ocr = other_children; ocr; ocr = nocr) {
  -	    nocr = ocr->next;
  -	    if (ocr->pid == -1)
  -		continue;
  -
  -	    waitret = waitpid(ocr->pid, &status, WNOHANG);
  -	    if (waitret == ocr->pid) {
  -		ocr->pid = -1;
  -		(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  -	    }
  -	    else if (waitret == 0) {
  -		(*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
  -		++not_dead_yet;
  -	    }
  -	    else if (waitret == -1) {
  -		/* uh what the heck? they didn't call unregister? */
  -		ocr->pid = -1;
  -		(*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
  -	    }
   	}
  -#endif
  +        ap_check_other_child();
   	if (!not_dead_yet) {
   	    /* nothing left to wait for */
   	    break;
  
  
  
  1.74      +1 -147    apache-2.0/src/modules/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/prefork.c,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- prefork.c	2000/03/31 09:05:10	1.73
  +++ prefork.c	2000/04/04 22:37:00	1.74
  @@ -158,19 +158,6 @@
   
   static int one_process = 0;
   
  -#ifdef HAS_OTHER_CHILD
  -/* used to maintain list of children which aren't part of the scoreboard */
  -typedef struct other_child_rec other_child_rec;
  -struct other_child_rec {
  -    other_child_rec *next;
  -    int pid;
  -    void (*maintenance) (int, void *, ap_wait_t);
  -    void *data;
  -    int write_fd;
  -};
  -static other_child_rec *other_children;
  -#endif
  -
   static ap_context_t *pconf;		/* Pool for config stuff */
   static ap_context_t *pchild;		/* Pool for httpd child stuff */
   
  @@ -796,115 +783,6 @@
   #define SAFE_ACCEPT(stmt) do {stmt;} while(0)
   #endif
   
  -
  -/*****************************************************************
  - * dealing with other children
  - */
  -
  -#ifdef HAS_OTHER_CHILD
  -API_EXPORT(void) ap_register_other_child(int pid,
  -		       void (*maintenance) (int reason, void *, ap_wait_t status),
  -			  void *data, int write_fd)
  -{
  -    other_child_rec *ocr;
  -
  -    ocr = ap_palloc(pconf, sizeof(*ocr));
  -    ocr->pid = pid;
  -    ocr->maintenance = maintenance;
  -    ocr->data = data;
  -    ocr->write_fd = write_fd;
  -    ocr->next = other_children;
  -    other_children = ocr;
  -}
  -
  -/* note that since this can be called by a maintenance function while we're
  - * scanning the other_children list, all scanners should protect themself
  - * by loading ocr->next before calling any maintenance function.
  - */
  -API_EXPORT(void) ap_unregister_other_child(void *data)
  -{
  -    other_child_rec **pocr, *nocr;
  -
  -    for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
  -	if ((*pocr)->data == data) {
  -	    nocr = (*pocr)->next;
  -	    (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
  -	    *pocr = nocr;
  -	    /* XXX: um, well we've just wasted some space in pconf ? */
  -	    return;
  -	}
  -    }
  -}
  -
  -/* test to ensure that the write_fds are all still writable, otherwise
  - * invoke the maintenance functions as appropriate */
  -static void probe_writable_fds(void)
  -{
  -    fd_set writable_fds;
  -    int fd_max;
  -    other_child_rec *ocr, *nocr;
  -    struct timeval tv;
  -    int rc;
  -
  -    if (other_children == NULL)
  -	return;
  -
  -    fd_max = 0;
  -    FD_ZERO(&writable_fds);
  -    do {
  -	for (ocr = other_children; ocr; ocr = ocr->next) {
  -	    if (ocr->write_fd == -1)
  -		continue;
  -	    FD_SET(ocr->write_fd, &writable_fds);
  -	    if (ocr->write_fd > fd_max) {
  -		fd_max = ocr->write_fd;
  -	    }
  -	}
  -	if (fd_max == 0)
  -	    return;
  -
  -	tv.tv_sec = 0;
  -	tv.tv_usec = 0;
  -	rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
  -    } while (rc == -1 && errno == EINTR);
  -
  -    if (rc == -1) {
  -	/* XXX: uhh this could be really bad, we could have a bad file
  -	 * descriptor due to a bug in one of the maintenance routines */
  -	ap_log_unixerr("probe_writable_fds", "select",
  -		    "could not probe writable fds", server_conf);
  -	return;
  -    }
  -    if (rc == 0)
  -	return;
  -
  -    for (ocr = other_children; ocr; ocr = nocr) {
  -	nocr = ocr->next;
  -	if (ocr->write_fd == -1)
  -	    continue;
  -	if (FD_ISSET(ocr->write_fd, &writable_fds))
  -	    continue;
  -	(*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
  -    }
  -}
  -
  -/* possibly reap an other_child, return 0 if yes, -1 if not */
  -static int reap_other_child(int pid, ap_wait_t status)
  -{
  -    other_child_rec *ocr, *nocr;
  -
  -    for (ocr = other_children; ocr; ocr = nocr) {
  -	nocr = ocr->next;
  -	if (ocr->pid != pid)
  -	    continue;
  -	ocr->pid = -1;
  -	(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  -	return 0;
  -    }
  -    return -1;
  -}
  -#endif
  -
   #if APR_HAS_SHARED_MEMORY
   #include "apr_shmem.h"
   
  @@ -1156,9 +1034,6 @@
       struct timeval tv;
       int waitret, tries;
       int not_dead_yet;
  -#ifdef HAS_OTHER_CHILD
  -    other_child_rec *ocr, *nocr;
  -#endif
   
       ap_sync_scoreboard_image();
   
  @@ -1229,29 +1104,8 @@
   			    "attempting to continue anyway", pid);
   		break;
   	    }
  -	}
  -#ifdef HAS_OTHER_CHILD
  -	for (ocr = other_children; ocr; ocr = nocr) {
  -	    nocr = ocr->next;
  -	    if (ocr->pid == -1)
  -		continue;
  -
  -	    waitret = waitpid(ocr->pid, &status, WNOHANG);
  -	    if (waitret == ocr->pid) {
  -		ocr->pid = -1;
  -		(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  -	    }
  -	    else if (waitret == 0) {
  -		(*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
  -		++not_dead_yet;
  -	    }
  -	    else if (waitret == -1) {
  -		/* uh what the heck? they didn't call unregister? */
  -		ocr->pid = -1;
  -		(*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
  -	    }
   	}
  -#endif
  +        ap_check_other_child();
   	if (!not_dead_yet) {
   	    /* nothing left to wait for */
   	    break;
  
  
  

Mime
View raw message