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