cvs commit: apache-apr/pthreads/src/main acceptlock.c http_accept.c http_config.c http_protocol.c

1999-07-19 Thread manoj
manoj   99/07/18 17:59:37

  Modified:pthreads/src/main acceptlock.c http_accept.c http_config.c
http_protocol.c
  Log:
  Some cleanup of signal handling. There were some stray bits of code that
  weren't cleaned up in the switchover to the pipe of death.
  
  Revision  ChangesPath
  1.12  +0 -2  apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -d -u -r1.11 -r1.12
  --- acceptlock.c  1999/06/23 19:13:00 1.11
  +++ acceptlock.c  1999/07/19 00:59:32 1.12
  @@ -308,9 +308,7 @@
   }
   #ifdef NEED_TO_BLOCK_SIGNALS_AROUND_PTHREAD_CALLS
   sigfillset(accept_block_mask);
  -sigdelset(accept_block_mask, SIGHUP);
   sigdelset(accept_block_mask, SIGTERM);
  -sigdelset(accept_block_mask, SIGWINCH);
   #endif
   ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
   }
  
  
  
  1.21  +1 -1  apache-apr/pthreads/src/main/http_accept.c
  
  Index: http_accept.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_accept.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -d -u -r1.20 -r1.21
  --- http_accept.c 1999/06/30 19:01:06 1.20
  +++ http_accept.c 1999/07/19 00:59:33 1.21
  @@ -66,7 +66,7 @@
   #include poll.h
   #include netinet/tcp.h
   
  -/* Indicates that all acceptor threads are dead after SIGWINCH and the worker
  +/* Indicates that all acceptor threads are dead and the worker
* threads can now exit */
   static int workers_may_exit = 0;
   static int requests_this_child;
  
  
  
  1.14  +0 -7  apache-apr/pthreads/src/main/http_config.c
  
  Index: http_config.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_config.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -d -u -r1.13 -r1.14
  --- http_config.c 1999/06/10 06:26:07 1.13
  +++ http_config.c 1999/07/19 00:59:33 1.14
  @@ -1524,13 +1524,6 @@
   {
   module *m;
   
  -#ifdef SIGHUP
  -signal(SIGHUP, SIG_IGN);
  -#endif
  -#ifdef SIGWINCH
  -signal(SIGWINCH, SIG_IGN);
  -#endif
  -
   for (m = top_module; m; m = m-next)
if (m-child_exit)
(*m-child_exit) (s, p);
  
  
  
  1.19  +0 -11 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.18
  retrieving revision 1.19
  diff -u -d -u -r1.18 -r1.19
  --- http_protocol.c   1999/06/10 06:26:09 1.18
  +++ http_protocol.c   1999/07/19 00:59:33 1.19
  @@ -810,17 +810,6 @@
   }
   /* 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);
   
   r-request_time = time(NULL);
  
  
  


cvs commit: apache-apr/pthreads/src/main acceptlock.c http_main.c

1999-07-19 Thread manoj
manoj   99/07/18 20:51:56

  Modified:pthreads/src/include scoreboard.h
   pthreads/src/main acceptlock.c http_main.c
  Log:
  pthread.h is a system include; use  instead of  in the #include to
  let make depend understand it correctly.
  
  Revision  ChangesPath
  1.9   +1 -1  apache-apr/pthreads/src/include/scoreboard.h
  
  Index: scoreboard.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/scoreboard.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -d -u -r1.8 -r1.9
  --- scoreboard.h  1999/06/10 06:25:56 1.8
  +++ scoreboard.h  1999/07/19 03:51:54 1.9
  @@ -57,7 +57,7 @@
   
   #ifndef APACHE_SCOREBOARD_H
   #define APACHE_SCOREBOARD_H
  -#include pthread.h
  +#include pthread.h
   #ifdef __cplusplus
   extern C {
   #endif
  
  
  
  1.13  +1 -1  apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -d -u -r1.12 -r1.13
  --- acceptlock.c  1999/07/19 00:59:32 1.12
  +++ acceptlock.c  1999/07/19 03:51:55 1.13
  @@ -77,7 +77,7 @@
   #include sys/shm.h
   #endif

  -#include pthread.h 
  +#include pthread.h
   
   /* Number of cross-process locks we're managing */
   static int lock_count;
  
  
  
  1.95  +1 -1  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.94
  retrieving revision 1.95
  diff -u -d -u -r1.94 -r1.95
  --- http_main.c   1999/07/19 02:02:02 1.94
  +++ http_main.c   1999/07/19 03:51:55 1.95
  @@ -98,7 +98,7 @@
   #include netinet/tcp.h 
   #include stdio.h 
   
  -#include pthread.h 
  +#include pthread.h
   /*#include initialization if any 
   #include threadabstractionlayer; 
   #include networkiolayer 
  
  
  


cvs commit: apache-apr/pthreads/src/main acceptlock.c

1999-06-23 Thread manoj
manoj   99/06/23 12:13:06

  Modified:pthreads/src/main acceptlock.c
  Log:
  fdqueue.h isn't needed here
  
  Revision  ChangesPath
  1.11  +0 -1  apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -d -u -r1.10 -r1.11
  --- acceptlock.c  1999/06/10 06:26:05 1.10
  +++ acceptlock.c  1999/06/23 19:13:00 1.11
  @@ -66,7 +66,6 @@
   #include http_vhost.h 
   #include util_script.h /* to force util_script.c linking */ 
   #include util_uri.h 
  -#include fdqueue.h
   #include acceptlock.h
   #include http_accept.h
   #include netinet/tcp.h 
  
  
  


cvs commit: apache-apr/pthreads/src/main acceptlock.c http_accept.c

1999-05-09 Thread manoj
manoj   99/05/09 01:39:32

  Modified:pthreads/src/include acceptlock.h
   pthreads/src/main acceptlock.c http_accept.c
  Log:
  Partial solution for the graceful restart during accept locking problem.
  Make sure that each thread checks the shutdown flag before attempting to
  get the cross-process accept lock, so that if one thread notices that
  it's time to die, the rest will soon after.
  
  Revision  ChangesPath
  1.5   +7 -2  apache-apr/pthreads/src/include/acceptlock.h
  
  Index: acceptlock.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/acceptlock.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- acceptlock.h  1999/04/17 03:35:53 1.4
  +++ acceptlock.h  1999/05/09 08:39:29 1.5
  @@ -62,6 +62,11 @@
   extern C {
   #endif
 
  +/* Prototypes for the intraprocess accept mutex functions */
  +void intra_mutex_init(pool *p, int);
  +void intra_mutex_on(int);
  +void intra_mutex_off(int);
  +
   /* Prototyps for the accept mutex functions. */
   #if defined (USE_USLOCK_SERIALIZED_ACCEPT)
   #define accept_mutex_child_init(x)
  @@ -79,13 +84,13 @@
   
   #elif defined (USE_SYSVSEM_SERIALIZED_ACCEPT)
   void accept_mutex_cleanup(void *);
  -void accept_mutex_child_init(pool *);
  +#define accept_mutex_child_init(x)
   void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
   #elif defined(USE_FCNTL_SERIALIZED_ACCEPT)
  -void accept_mutex_child_init(pool *);
  +#define accept_mutex_child_init(x)
   void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
  
  
  
  1.9   +10 -29apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- acceptlock.c  1999/04/22 19:09:01 1.8
  +++ acceptlock.c  1999/05/09 08:39:30 1.9
  @@ -83,25 +83,28 @@
   /* Number of cross-process locks we're managing */
   static int lock_count;
   
  +/* Number of intra-process locks we're managing */
  +static int intra_lock_count;
  +
   /* Intraprocess locking used by other serialization techniques */
  -#ifdef NEED_INTRAPROCESS_SERIALIZED_ACCEPT
   static pthread_mutex_t *intra_mutex = NULL;
   
   static void intra_mutex_cleanup(void *foo)
   {
   int i;
   
  -for (i = 0; i  lock_count; i++) {
  +for (i = 0; i  intra_lock_count; i++) {
   (void) pthread_mutex_destroy(intra_mutex[i]);
   }
   }
   
  -static void intra_mutex_init(pool *p)
  +void intra_mutex_init(pool *p, int number_of_locks)
   {
   int i;
   
  -intra_mutex = (pthread_mutex_t *)ap_palloc(p, lock_count * 
sizeof(pthread_mutex_t ));
  -for (i = 0; i  lock_count; i++) {
  +intra_lock_count = number_of_locks;
  +intra_mutex = (pthread_mutex_t *)ap_palloc(p, intra_lock_count * 
sizeof(pthread_mutex_t ));
  +for (i = 0; i  intra_lock_count; i++) {
   if (pthread_mutex_init(intra_mutex[i], NULL) != 0) {
   perror(intra_mutex_init);
clean_child_exit(APEXIT_CHILDFATAL);
  @@ -110,7 +113,7 @@
   ap_register_cleanup(p, NULL, intra_mutex_cleanup, ap_null_cleanup);
   }
   
  -static void intra_mutex_on(int locknum)
  +void intra_mutex_on(int locknum)
   {
   if ((errno = pthread_mutex_lock(intra_mutex[locknum])) != 0) {
   ap_log_error(APLOG_MARK, APLOG_EMERG, 
  @@ -119,7 +122,7 @@
   }
   }
   
  -static void intra_mutex_off(int locknum)
  +void intra_mutex_off(int locknum)
   {
   if (pthread_mutex_unlock(intra_mutex[locknum]) != 0) {
   ap_log_error(APLOG_MARK, APLOG_EMERG, 
  @@ -127,11 +130,6 @@
 Error releasing intraprocess lock. Exiting!);
   }
   }
  -#else /* NEED_INTRAPROCESS_SERIALIZED_ACCEPT */
  -#define intra_mutex_init(x)
  -#define intra_mutex_on(x)
  -#define intra_mutex_off(x)
  -#endif /* NEED_INTRAPROCESS_SERIALIZED_ACCEPT */
   
   #if defined(USE_FCNTL_SERIALIZED_ACCEPT) || 
defined(USE_FLOCK_SERIALIZED_ACCEPT)
   static void init_lock_fname(pool *p)
  @@ -454,14 +452,8 @@
   }
   }
   
  -void accept_mutex_child_init(pool *p)
  -{
  -intra_mutex_init(p);
  -}
  -
   void accept_mutex_on(int locknum)
   {
  -intra_mutex_on(locknum);
   if (semop(sem_id[locknum], op_on, 1)  0) {
perror(accept_mutex_on);
clean_child_exit(APEXIT_CHILDFATAL);
  @@ -474,7 +466,6 @@
perror(accept_mutex_off);
clean_child_exit(APEXIT_CHILDFATAL);
   }
  -intra_mutex_off(locknum);
   }
   
   #elif defined(USE_FCNTL_SERIALIZED_ACCEPT)
  @@ -519,16 +510,10 @@
   }
   }
   
  -void accept_mutex_child_init(pool *p)
  -{
  -intra_mutex_init(p);
  -}
  -
   void accept_mutex_on(int 

Re: cvs commit: apache-apr/pthreads/src/main acceptlock.c http_accept.c

1999-05-09 Thread Dirk-Willem van Gulik


On 9 May 1999 [EMAIL PROTECTED] wrote:

   Partial solution for the graceful restart during accept locking problem.
   Make sure that each thread checks the shutdown flag before attempting to
   get the cross-process accept lock, so that if one thread notices that
   it's time to die, the rest will soon after.
   
   Revision  ChangesPath
   1.5   +7 -2  apache-apr/pthreads/src/include/acceptlock.h

Good stuff ! Seems to make a/the difference.

Dw



cvs commit: apache-apr/pthreads/src/main acceptlock.c

1999-04-22 Thread manoj
manoj   99/04/22 12:09:02

  Modified:pthreads/src/main acceptlock.c
  Log:
  Go back to old behavior of retrying flock and fcntl when EINTR is
  received. Our worker and acceptor threads don't receive signals anyway,
  and the old code would make us retry fcntl if we got any error besides
  EINTR.
  
  Revision  ChangesPath
  1.8   +7 -7  apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -u -r1.7 -r1.8
  --- acceptlock.c  1999/04/17 03:35:54 1.7
  +++ acceptlock.c  1999/04/22 19:09:01 1.8
  @@ -530,11 +530,11 @@
   
   intra_mutex_on(locknum);
   while ((ret = fcntl(lock_fd[locknum], F_SETLKW, lock_it))  0  
  -errno != EINTR) {
  +errno == EINTR) {
/* nop */
   }
   
  -if (ret  0  errno != EINTR) {
  +if (ret  0) {
ap_log_error(APLOG_MARK, APLOG_EMERG, (const server_rec*) 
ap_get_server_conf(),
fcntl: F_SETLKW: Error getting accept lock, exiting!  
Perhaps you need to use the LockFile directive to place 
  @@ -548,10 +548,10 @@
   int ret;
   
   while ((ret = fcntl(lock_fd[locknum], F_SETLKW, unlock_it))  0 
  - errno != EINTR) {
  + errno == EINTR) {
/* nop */
   }
  -if (ret  0  errno != EINTR) {
  +if (ret  0) {
ap_log_error(APLOG_MARK, APLOG_EMERG, (const server_rec*) 
ap_get_server_conf(),
fcntl: F_SETLKW: Error freeing accept lock, exiting!  
Perhaps you need to use the LockFile directive to place 
  @@ -630,10 +630,10 @@
   int ret;
   
   intra_mutex_on(locknum);
  -while ((ret = flock(lock_fd[locknum], LOCK_EX))  0  errno != EINTR)
  +while ((ret = flock(lock_fd[locknum], LOCK_EX))  0  errno == EINTR)
   continue;
   
  -if (ret  0  errno != EINTR) {
  +if (ret  0) {
   ap_log_error(APLOG_MARK, APLOG_EMERG, 
 (const server_rec *) ap_get_server_conf(),
 flock: LOCK_EX: Error getting accept lock. Exiting!);
  @@ -643,7 +643,7 @@
   
   void accept_mutex_off(int locknum)
   {
  -if (flock(lock_fd[locknum], LOCK_UN)  0  errno != EINTR) {
  +if (flock(lock_fd[locknum], LOCK_UN)  0) {
   ap_log_error(APLOG_MARK, APLOG_EMERG, 
 (const server_rec *) ap_get_server_conf(),
 flock: LOCK_UN: Error freeing accept lock. Exiting!);
  
  
  


cvs commit: apache-apr/pthreads/src/main acceptlock.c

1999-04-16 Thread manoj
manoj   99/04/15 21:43:02

  Modified:pthreads/src/main acceptlock.c
  Log:
  For pthread serialization: ifdef out an added signal mask call that
  isn't needed in the current server architecture, and fix up that same
  code so it can be turned on again if need be.
  
  Revision  ChangesPath
  1.6   +19 -7 apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -u -r1.5 -r1.6
  --- acceptlock.c  1999/04/14 22:44:56 1.5
  +++ acceptlock.c  1999/04/16 04:43:01 1.6
  @@ -175,8 +175,13 @@
   
   static pthread_mutex_t *accept_mutex = (void *)(caddr_t) -1;
   static int *have_accept_mutex;
  +/* The sections surrounded with this ifdef are not needed because of the
  + * sigwait thread. They may be turned back on, though, depending on how the
  + * port to nonthreaded mode goes */
  +#ifdef NEED_TO_BLOCK_SIGNALS_AROUND_PTHREAD_CALLS
   static sigset_t accept_block_mask;
  -static sigset_t accept_previous_mask;
  +static sigset_t *accept_previous_masks = NULL;
  +#endif
   
   void accept_mutex_child_cleanup(void *foo)
   {
  @@ -193,6 +198,9 @@
   void accept_mutex_child_init(pool *p)
   {
   ap_register_cleanup(p, NULL, accept_mutex_child_cleanup, 
ap_null_cleanup);
  +#ifdef NEED_TO_BLOCK_SIGNALS_AROUND_PTHREAD_CALLS
  +accept_previous_masks = ap_palloc(p, lock_count * sizeof(sigset_t));
  +#endif
   }
   
   void accept_mutex_cleanup(void *foo)
  @@ -249,10 +257,12 @@
   perror(pthread_mutexattr_destroy);
   exit(APEXIT_INIT);
   }
  +#ifdef NEED_TO_BLOCK_SIGNALS_AROUND_PTHREAD_CALLS
   sigfillset(accept_block_mask);
   sigdelset(accept_block_mask, SIGHUP);
   sigdelset(accept_block_mask, SIGTERM);
   sigdelset(accept_block_mask, SIGWINCH);
  +#endif
   ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
   }
   
  @@ -260,10 +270,10 @@
   {
   int err;
   
  -/* Already blocking out all signals in worker threads. */
  -#if 0
  -if (sigprocmask(SIG_BLOCK, accept_block_mask, accept_previous_mask)) {
  - perror(sigprocmask(SIG_BLOCK));
  +#ifdef NEED_TO_BLOCK_SIGNALS_AROUND_PTHREAD_CALLS
  +if (pthread_sigmask(SIG_BLOCK, accept_block_mask,
  +accept_previous_mask[locknum])) {
  + perror(pthread_sigmask(SIG_BLOCK));
clean_child_exit(APEXIT_CHILDFATAL);
   }
   #endif
  @@ -298,10 +308,12 @@
* hits.
*/
   have_accept_mutex[locknum] = 0;
  -if (sigprocmask(SIG_SETMASK, accept_previous_mask, NULL)) {
  - perror(sigprocmask(SIG_SETMASK));
  +#ifdef NEED_TO_BLOCK_SIGNALS_AROUND_PTHREAD_CALLS
  +if (pthread_sigmask(SIG_SETMASK, accept_previous_mask[locknum], NULL)) {
  + perror(pthread_sigmask(SIG_SETMASK));
clean_child_exit(1);
   }
  +#endif
   }
   
   #elif defined (USE_SYSVSEM_SERIALIZED_ACCEPT)
  
  
  


cvs commit: apache-apr/pthreads/src/main acceptlock.c

1999-04-14 Thread manoj
manoj   99/04/13 23:26:12

  Modified:pthreads/src/main acceptlock.c
  Log:
  Make USE_PTHREAD_SERIALIZED_ACCEPT functional. A few bugs are fixed, and
  mmap usage is optimized (I hope).
  
  Revision  ChangesPath
  1.4   +48 -44apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- acceptlock.c  1999/04/09 03:15:40 1.3
  +++ acceptlock.c  1999/04/14 06:26:12 1.4
  @@ -170,7 +170,7 @@
   
   #include pthread.h
   
  -static pthread_mutex_t **accept_mutex = (void *)(caddr_t) -1;
  +static pthread_mutex_t *accept_mutex = (void *)(caddr_t) -1;
   static int *have_accept_mutex;
   static sigset_t accept_block_mask;
   static sigset_t accept_previous_mask;
  @@ -179,10 +179,11 @@
   {
   int i;
  
  -for (i = 0; i  ap_acceptors_per_child; i++) {
  -if (accept_mutex[i] != (void *)(caddr_t)-1
  -have_accept_mutex[i]) {
  - pthread_mutex_unlock(accept_mutex[i]);
  +if (accept_mutex != (void *)(caddr_t)-1) {
  +for (i = 0; i  ap_acceptors_per_child; i++) {
  + if (have_accept_mutex[i]) {
  + pthread_mutex_unlock(accept_mutex[i]);
  +}
}
   }
   }
  @@ -195,13 +196,12 @@
   {
   int i;
  
  -for (i = 0; i  ap_acceptors_per_child; i++) {
  -if (accept_mutex[i] != (void *)(caddr_t)-1
  -munmap((caddr_t) accept_mutex[i], sizeof(pthread_mutex_t))) {
  - perror(munmap);
  - }
  - accept_mutex[i] = (void *)(caddr_t)-1;
  +if (accept_mutex != (void *)(caddr_t)-1
  + munmap((caddr_t) accept_mutex,
  +  sizeof(pthread_mutex_t) * ap_acceptors_per_child)) {
  + perror(munmap);
   }
  +accept_mutex = (void *)(caddr_t)-1;
   }
   
   void accept_mutex_init(pool *p)
  @@ -210,56 +210,60 @@
   int fd;
   int i;
  
  -accept_mutex = (pthread_mutex_t *)ap_palloc(p, 
  - ap_acceptors_per_child * sizeof(pthread_mutex_t *));
   have_accept_mutex = (int *)ap_palloc(p, 
ap_acceptors_per_child * sizeof(int));
   
  -
  +fd = open(/dev/zero, O_RDWR);
  +if (fd == -1) {
  +perror(open(/dev/zero));
  +exit(APEXIT_INIT);
  +}
  +accept_mutex = (pthread_mutex_t *) mmap((caddr_t) 0, 
  +   sizeof(pthread_mutex_t) * ap_acceptors_per_child, 
  +PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  +if (accept_mutex == (void *) (caddr_t) - 1) {
  +perror(mmap);
  +exit(APEXIT_INIT);
  +}
  +close(fd);
  +if ((errno = pthread_mutexattr_init(mattr))) {
  +perror(pthread_mutexattr_init);
  +exit(APEXIT_INIT);
  +}
  +if ((errno = pthread_mutexattr_setpshared(mattr,
  +   PTHREAD_PROCESS_SHARED))) {
  +perror(pthread_mutexattr_setpshared);
  +exit(APEXIT_INIT);
  +}
   for (i = 0; i  ap_acceptors_per_child; i++) {
  -fd = open(/dev/zero, O_RDWR);
  - if (fd == -1) {
  - perror(open(/dev/zero));
  - exit(APEXIT_INIT);
  - }
  - accept_mutex[i] = (pthread_mutex_t *) mmap((caddr_t) 0, 
  -sizeof(*accept_mutex),
  -PROT_READ | PROT_WRITE, 
MAP_SHARED, fd, 0);
  - if (accept_mutex[i] == (void *) (caddr_t) - 1) {
  - perror(mmap);
  - exit(APEXIT_INIT);
  - }
  - close(fd);
  - if ((errno = pthread_mutexattr_init(mattr))) {
  - perror(pthread_mutexattr_init);
  - exit(APEXIT_INIT);
  - }
  - if ((errno = pthread_mutexattr_setpshared(mattr,
  -   PTHREAD_PROCESS_SHARED))) {
  - perror(pthread_mutexattr_setpshared);
  - exit(APEXIT_INIT);
  - }
  - if ((errno = pthread_mutex_init(accept_mutex, mattr))) {
  + if ((errno = pthread_mutex_init(accept_mutex[i], mattr))) {
perror(pthread_mutex_init);
exit(APEXIT_INIT);
}
  - sigfillset(accept_block_mask);
  - sigdelset(accept_block_mask, SIGHUP);
  - sigdelset(accept_block_mask, SIGTERM);
  - sigdelset(accept_block_mask, SIGWINCH);
  - ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
   }
  +if ((errno = pthread_mutexattr_destroy(mattr))) {
  +perror(pthread_mutexattr_destroy);
  +exit(APEXIT_INIT);
  +}
  +sigfillset(accept_block_mask);
  +sigdelset(accept_block_mask, SIGHUP);
  +sigdelset(accept_block_mask, SIGTERM);
  +sigdelset(accept_block_mask, SIGWINCH);
  +ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
   }
   
   void 

cvs commit: apache-apr/pthreads/src/main acceptlock.c http_accept.c http_main.c

1999-04-14 Thread manoj
manoj   99/04/14 15:44:58

  Modified:pthreads/src/include acceptlock.h http_accept.h
   pthreads/src/main acceptlock.c http_accept.c http_main.c
  Log:
  Cleanup and bug fixes. This patch removes the link between
  ap_acceptors_per_child and the number of listen fds, to support the new
  poll-accept model. As a result, we don't create a bunch of accept
  mutexes we don't need, and there isn't a pile of phantom threads that
  we attempt to count and operate on.
  
  Revision  ChangesPath
  1.3   +7 -7  apache-apr/pthreads/src/include/acceptlock.h
  
  Index: acceptlock.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/acceptlock.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- acceptlock.h  1999/03/07 00:47:43 1.2
  +++ acceptlock.h  1999/04/14 22:44:55 1.3
  @@ -65,7 +65,7 @@
   /* Prototyps for the accept mutex functions. */
   #if defined (USE_USLOCK_SERIALIZED_ACCEPT)
   #define accept_mutex_child_init(x)
  -void accept_mutex_init(pool *);
  +void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
  @@ -73,33 +73,33 @@
   void accept_mutex_child_cleanup(void *);
   void accept_mutex_child_init(pool *);
   void accept_mutex_cleanup(void *);
  -void accept_mutex_init(pool *);
  +void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
   #elif defined (USE_SYSVSEM_SERIALIZED_ACCEPT)
   void accept_mutex_cleanup(void *);
  -void accept_mutex_init(pool *);
  +void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
   #elif defined(USE_FCNTL_SERIALIZED_ACCEPT)
   #define accept_mutex_child_init(x)
  -void accept_mutex_init(pool *);
  +void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
   #elif defined(USE_FLOCK_SERIALIZED_ACCEPT)
   void accept_mutex_cleanup(void *);
   void accept_mutex_child_init(pool *);
  -void accept_mutex_init(pool *);
  +void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
   #elif defined(USE_OS2SEM_SERIALIZED_ACCEPT)
   void accept_mutex_cleanup(void *);
   void accept_mutex_child_init(pool *);
  -void accept_mutex_init(pool *);
  +void accept_mutex_init(pool *, int);
   void accept_mutex_on(int);
   void accept_mutex_off(int);
   
  @@ -109,7 +109,7 @@
* the sockets. */
   #define NO_SERIALIZED_ACCEPT
   #define accept_mutex_child_init(x)
  -#define accept_mutex_init(x)
  +#define accept_mutex_init(x, y)
   #define accept_mutex_on(x)
   #define accept_mutex_off(x)
   #endif
  
  
  
  1.4   +2 -2  apache-apr/pthreads/src/include/http_accept.h
  
  Index: http_accept.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/http_accept.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- http_accept.h 1999/04/14 21:38:28 1.3
  +++ http_accept.h 1999/04/14 22:44:55 1.4
  @@ -79,8 +79,8 @@
   #define USE_ACCEPT_QUEUE
   /*#define USE_MULTI_ACCEPT*/
   
  -void accept_parent_init(pool*);
  -void accept_child_init(pool*, int, int);
  +void accept_parent_init(pool*, int);
  +void accept_child_init(pool*, int);
   void start_accepting_connections(int);
   int  get_connection(struct sockaddr *);
   void stop_accepting_connections(pool*);
  
  
  
  1.5   +34 -26apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- acceptlock.c  1999/04/14 06:26:12 1.4
  +++ acceptlock.c  1999/04/14 22:44:56 1.5
  @@ -79,6 +79,8 @@

   #include pthread.h 
   
  +/* Number of cross-process locks we're managing */
  +static int lock_count;
   
   #if defined(USE_FCNTL_SERIALIZED_ACCEPT) || 
defined(USE_FLOCK_SERIALIZED_ACCEPT)
   static void init_lock_fname(pool *p)
  @@ -102,15 +104,16 @@
   
   
   
  -void accept_mutex_init(pool *p)
  +void accept_mutex_init(pool *p, int number_of_locks)
   {
   ptrdiff_t old;
   usptr_t *us;
   int i;
   
  -uslock = (ulock_t *)ap_palloc(p, ap_acceptors_per_child * 
sizeof(ulock_t));
  +lock_count = number_of_locks;
  +uslock = (ulock_t *)ap_palloc(p, lock_count * sizeof(ulock_t));
   
  -for (i = 0; i  ap_acceptors_per_child; i++) {
  +for (i = 0; i  lock_count; i++) {
   /* default is 8, allocate enough for all the children plus the parent */
   if ((old = usconfig(CONF_INITUSERS, HARD_SERVER_LIMIT + 1)) == -1) {
perror(usconfig(CONF_INITUSERS));
  @@ -180,7 +183,7 @@
   int i;
  
   if (accept_mutex != (void *)(caddr_t)-1) {
  

cvs commit: apache-apr/pthreads/src/main acceptlock.c

1999-04-09 Thread manoj
manoj   99/04/08 20:15:40

  Modified:pthreads/src/main acceptlock.c
  Log:
  Fix acceptlock bugs found during warning scrubbing. expand_lock_fname is
  now static. Also, the psprintf in that function had an extra argument
  (the parent process pid), which wasn't used, and can't be used in child
  processes, but which is useful.
  
  So, we use it by create a new init_lock_fname which is used only
  in the parent process so that the getpid() call returns the expected
  result.
  
  Revision  ChangesPath
  1.3   +10 -5 apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- acceptlock.c  1999/03/07 00:47:49 1.2
  +++ acceptlock.c  1999/04/09 03:15:40 1.3
  @@ -81,14 +81,17 @@
   
   
   #if defined(USE_FCNTL_SERIALIZED_ACCEPT) || 
defined(USE_FLOCK_SERIALIZED_ACCEPT)
  -char * expand_lock_fname(pool *p, int i)
  +static void init_lock_fname(pool *p)
   {
  -char *fname; 
   /*  possibly bogus cast */
  -fname = ap_psprintf(p, %s.%d,
  - ap_server_root_relative(p, ap_lock_fname), i, (unsigned long)getpid());
  -return fname;
  +ap_lock_fname = ap_psprintf(p, %s.%lu,
  +ap_server_root_relative(p, ap_lock_fname), (unsigned long)getpid());
   }
  +
  +static char * expand_lock_fname(pool *p, int i)
  +{
  +return ap_psprintf(p, %s.%d, ap_lock_fname, i);
  +}
   #endif
   
   #if defined (USE_USLOCK_SERIALIZED_ACCEPT)
  @@ -423,6 +426,7 @@
   unlock_it.l_type = F_UNLCK;  /* set exclusive/write lock */
   unlock_it.l_pid = 0; /* pid not actually interesting */
   
  +init_lock_fname(p);
   for (i = 0; i  ap_acceptors_per_child; i++) {
   lock_fname = expand_lock_fname(p, i);
lock_fd[i] = ap_popenf(p, lock_fname, 
  @@ -517,6 +521,7 @@
   char *lock_fname;
   lock_fd = (int *)ap_palloc(p, ap_acceptors_per_child * sizeof(int *));
 
  +init_lock_fname(p);
   for (i = 0; i  ap_acceptors_per_child; i++) {
   lock_fname = expand_lock_fname(p, i);
   unlink(lock_fname);
  
  
  


cvs commit: apache-apr/pthreads/src/main acceptlock.c scoreboard.c

1999-03-07 Thread rbb
rbb 99/03/06 16:47:53

  Modified:pthreads/src/include acceptlock.h httpd.h
   pthreads/src/main acceptlock.c scoreboard.c
  Log:
  Modifications to make the acceptlock abstractions work on Linux.
  
  Revision  ChangesPath
  1.2   +0 -1  apache-apr/pthreads/src/include/acceptlock.h
  
  Index: acceptlock.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/acceptlock.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- acceptlock.h  1999/03/05 16:45:57 1.1
  +++ acceptlock.h  1999/03/07 00:47:43 1.2
  @@ -90,7 +90,6 @@
   void accept_mutex_off(int);
   
   #elif defined(USE_FLOCK_SERIALIZED_ACCEPT)
  -#define accept_mutex_child_init(x)
   void accept_mutex_cleanup(void *);
   void accept_mutex_child_init(pool *);
   void accept_mutex_init(pool *);
  
  
  
  1.10  +1 -1  apache-apr/pthreads/src/include/httpd.h
  
  Index: httpd.h
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/include/httpd.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- httpd.h   1999/02/24 20:30:14 1.9
  +++ httpd.h   1999/03/07 00:47:44 1.10
  @@ -1039,7 +1039,7 @@
   API_EXPORT(int) ap_can_exec(const struct stat *);
   API_EXPORT(void) ap_chdir_file(const char *file);
   API_EXPORT(int) ap_get_max_daemons(void);
  -server_rec * get_server_conf(void);
  +API_EXPORT(const server_rec *) ap_get_server_conf(void);
   
   #ifndef HAVE_CANONICAL_FILENAME
   /*
  
  
  
  1.2   +28 -24apache-apr/pthreads/src/main/acceptlock.c
  
  Index: acceptlock.c
  ===
  RCS file: /home/cvs/apache-apr/pthreads/src/main/acceptlock.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- acceptlock.c  1999/03/05 16:45:55 1.1
  +++ acceptlock.c  1999/03/07 00:47:49 1.2
  @@ -478,31 +478,32 @@
   void accept_mutex_cleanup(void *foo)
   {
   int i;
  -
  +  
   char * lock_fname;
   for (i = 0; i  ap_acceptors_per_child; i++) {
   lock_fname = expand_lock_fname(foo, i);
  - unlink(lock_fname);
  +unlink(lock_fname);
   }
   }
   
   /*
* Initialize mutex lock.
* Done by each child at it's birth
  - */
  + */ 
   void accept_mutex_child_init(pool *p)
   {
   int i;
  -
  +  
   for (i = 0; i  ap_acceptors_per_child; i++) {
   char *lock_fname = expand_lock_fname(p, i);
  -  
  - lock_fd[i] = ap_popenf(p, lock_fname, O_WRONLY, 0600);
  - if (lock_fd[i] == -1) {
  -   ap_log_error(APLOG_MARK, APLOG_EMERG, ap_get_server_conf(),
  +
  +lock_fd[i] = ap_popenf(p, lock_fname, O_WRONLY, 0600);
  +if (lock_fd[i] == -1) {
  +   ap_log_error(APLOG_MARK, APLOG_EMERG, 
  +(const server_rec *)ap_get_server_conf(),
   Child cannot open lock file: %s, lock_fname);
  clean_child_exit(APEXIT_CHILDINIT);
  - }
  +}
   }
   }
   
  @@ -513,20 +514,21 @@
   void accept_mutex_init(pool *p)
   {
   int i;
  -char * lock_fname;
  +char *lock_fname;
   lock_fd = (int *)ap_palloc(p, ap_acceptors_per_child * sizeof(int *));
  -
  +  
   for (i = 0; i  ap_acceptors_per_child; i++) {
   lock_fname = expand_lock_fname(p, i);
  - unlink(lock_fname);
  - lock_fd[i] = ap_popenf(p, lock_fname, 
  +unlink(lock_fname);
  +lock_fd[i] = ap_popenf(p, lock_fname, 
   O_CREAT | O_WRONLY | O_EXCL, 0600);
  - if (lock_fd[i] == -1) {
  -   ap_log_error(APLOG_MARK, APLOG_EMERG, ap_get_server_conf(),
  -Parent cannot open lock file: %s, lock_fname);
  -   exit(APEXIT_INIT);
  - }
  - ap_register_cleanup(p, p, accept_mutex_cleanup, ap_null_cleanup);
  +if (lock_fd[i] == -1) {
  + ap_log_error(APLOG_MARK, APLOG_EMERG, 
  +  (const server_rec *) ap_get_server_conf(), 
  +  Parent cannot open lock file: %s, lock_fname);
  +exit(APEXIT_INIT);
  +}
  +ap_register_cleanup(p, p, accept_mutex_cleanup, ap_null_cleanup);
   }
   }
   
  @@ -535,11 +537,12 @@
   int ret;
   
   while ((ret = flock(lock_fd[locknum], LOCK_EX))  0  errno != EINTR)
  - continue;
  +continue;
   
   if (ret  0  errno != EINTR) {
  - ap_log_error(APLOG_MARK, APLOG_EMERG, ap_get_server_conf(),
  - flock: LOCK_EX: Error getting accept lock. Exiting!);
  +ap_log_error(APLOG_MARK, APLOG_EMERG, 
  +  (const server_rec *) ap_get_server_conf(),
  +  flock: LOCK_EX: Error getting accept lock. Exiting!);
clean_child_exit(APEXIT_CHILDFATAL);
   }
   }
  @@ -547,8 +550,9 @@
   void accept_mutex_off(int