You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 2000/01/26 00:04:46 UTC
cvs commit: apache-2.0/src/lib/apr/test testthread.c
rbb 00/01/25 15:04:44
Modified: src/lib/apr/include apr_portable.h
src/lib/apr/locks/unix crossproc.c locks.c locks.h
src/lib/apr/misc/unix start.c
src/lib/apr/test testthread.c
Log:
Take a couple of values that were static for all locks out of the lock
structure. These values are now created once and used for all locks.
Revision Changes Path
1.21 +0 -4 apache-2.0/src/lib/apr/include/apr_portable.h
Index: apr_portable.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_portable.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- apr_portable.h 2000/01/24 13:59:01 1.20
+++ apr_portable.h 2000/01/25 23:04:23 1.21
@@ -149,12 +149,8 @@
struct os_lock_t {
#if APR_USE_SYSVSEM_SERIALIZE
int crossproc;
- struct sembuf op_on;
- struct sembuf op_off;
#elif APR_USE_FCNTL_SERIALIZE
int crossproc;
- struct flock lock_it;
- struct flock unlock_it;
#elif APR_USE_PROC_PTHREAD_SERIALIZE
pthread_mutex_t *crossproc;
#elif APR_USE_FLOCK_SERIALIZE
1.12 +41 -24 apache-2.0/src/lib/apr/locks/unix/crossproc.c
Index: crossproc.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/crossproc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- crossproc.c 2000/01/23 01:13:46 1.11
+++ crossproc.c 2000/01/25 23:04:27 1.12
@@ -56,6 +56,19 @@
#include "locks.h"
#if defined (USE_SYSVSEM_SERIALIZE)
+
+static struct sembuf op_on;
+static struct sembuf op_off;
+
+void setup_lock() {
+ op_on.sem_num = 0;
+ op_on.sem_op = -1;
+ op_on.sem_flg = SEM_UNDO;
+ op_off.sem_num = 0;
+ op_off.sem_op = 1;
+ op_off.sem_flg = SEM_UNDO;
+}
+
ap_status_t lock_cleanup(void *lock_)
{
struct lock_t *lock=lock_;
@@ -84,14 +97,6 @@
lock_cleanup(new);
return errno;
}
- /* preinitialize these */
- new->op_on.sem_num = 0;
- new->op_on.sem_op = -1;
- new->op_on.sem_flg = SEM_UNDO;
- new->op_off.sem_num = 0;
- new->op_off.sem_op = 1;
- new->op_off.sem_flg = SEM_UNDO;
-
new->curr_locked = 0;
ap_register_cleanup(new->cntxt, (void *)new, lock_cleanup, ap_null_cleanup);
return APR_SUCCESS;
@@ -100,7 +105,7 @@
ap_status_t lock_inter(struct lock_t *lock)
{
lock->curr_locked = 1;
- if (semop(lock->interproc, &lock->op_on, 1) < 0) {
+ if (semop(lock->interproc, &op_on, 1) < 0) {
return errno;
}
return APR_SUCCESS;
@@ -108,7 +113,7 @@
ap_status_t unlock_inter(struct lock_t *lock)
{
- if (semop(lock->interproc, &lock->op_off, 1) < 0) {
+ if (semop(lock->interproc, &op_off, 1) < 0) {
return errno;
}
lock->curr_locked = 0;
@@ -133,6 +138,9 @@
#elif defined (USE_PROC_PTHREAD_SERIALIZE)
+void setup_lock() {
+}
+
ap_status_t lock_cleanup(struct lock_t *lock)
{
if (lock->curr_locked == 1) {
@@ -227,12 +235,28 @@
#elif defined (USE_FCNTL_SERIALIZE)
+static struct flock lock_it;
+static struct flock unlock_it;
+
+void setup_lock() {
+ lock_it.l_whence = SEEK_SET; /* from current point */
+ lock_it.l_start = 0; /* -"- */
+ lock_it.l_len = 0; /* until end of file */
+ lock_it.l_type = F_WRLCK; /* set exclusive/write lock */
+ lock_it.l_pid = 0; /* pid not actually interesting */
+ unlock_it.l_whence = SEEK_SET; /* from current point */
+ unlock_it.l_start = 0; /* -"- */
+ unlock_it.l_len = 0; /* until end of file */
+ unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */
+ unlock_it.l_pid = 0; /* pid not actually interesting */
+}
+
static ap_status_t lock_cleanup(void *lock_)
{
struct lock_t *lock=lock_;
if (lock->curr_locked == 1) {
- if (fcntl(lock->interproc, F_SETLKW, &lock->unlock_it) < 0) {
+ if (fcntl(lock->interproc, F_SETLKW, &unlock_it) < 0) {
return errno;
}
lock->curr_locked=0;
@@ -248,17 +272,6 @@
lock_cleanup(new);
return errno;
}
- /* preinitialize these */
- new->lock_it.l_whence = SEEK_SET; /* from current point */
- new->lock_it.l_start = 0; /* -"- */
- new->lock_it.l_len = 0; /* until end of file */
- new->lock_it.l_type = F_WRLCK; /* set exclusive/write lock */
- new->lock_it.l_pid = 0; /* pid not actually interesting */
- new->unlock_it.l_whence = SEEK_SET; /* from current point */
- new->unlock_it.l_start = 0; /* -"- */
- new->unlock_it.l_len = 0; /* until end of file */
- new->unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */
- new->unlock_it.l_pid = 0; /* pid not actually interesting */
new->curr_locked=0;
unlink(new->fname);
@@ -269,7 +282,7 @@
ap_status_t lock_inter(struct lock_t *lock)
{
lock->curr_locked=1;
- if (fcntl(lock->interproc, F_SETLKW, &lock->lock_it) < 0) {
+ if (fcntl(lock->interproc, F_SETLKW, &lock_it) < 0) {
return errno;
}
return APR_SUCCESS;
@@ -277,7 +290,7 @@
ap_status_t unlock_inter(struct lock_t *lock)
{
- if (fcntl(lock->interproc, F_SETLKW, &lock->unlock_it) < 0) {
+ if (fcntl(lock->interproc, F_SETLKW, &unlock_it) < 0) {
return errno;
}
lock->curr_locked=0;
@@ -300,6 +313,10 @@
}
#elif defined (USE_FLOCK_SERIALIZE)
+
+void setup_lock() {
+}
+
ap_status_t lock_cleanup(struct lock_t *lock)
{
if (lock->curr_locked == 1) {
1.17 +0 -14 apache-2.0/src/lib/apr/locks/unix/locks.c
Index: locks.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/locks.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- locks.c 1999/12/06 18:58:26 1.16
+++ locks.c 2000/01/25 23:04:27 1.17
@@ -264,13 +264,6 @@
return APR_ENOLOCK;
}
oslock->crossproc = lock->interproc;
-#if USE_SYSVSEM_SERIALIZE
- oslock->op_on = lock->op_on;
- oslock->op_off = lock->op_off;
-#elif USE_FCNTL_SERIALIZE
- oslock->lock_it = lock->lock_it;
- oslock->unlock_it = lock->unlock_it;
-#endif
#if APR_HAS_THREADS
#if USE_PTHREAD_SERIALIZE
oslock->intraproc = lock->intraproc;
@@ -298,13 +291,6 @@
(*lock)->cntxt = cont;
}
(*lock)->interproc = thelock->crossproc;
-#if defined (USE_SYSVSEM_SERIALIZE)
- (*lock)->op_on = thelock->op_on;
- (*lock)->op_off = thelock->op_off;
-#elif defined (USE_FCNTL_SERIALIZE)
- (*lock)->lock_it = thelock->lock_it;
- (*lock)->unlock_it = thelock->unlock_it;
-#endif
#if APR_HAS_THREADS
#if defined (USE_PTHREAD_SERIALIZE)
(*lock)->intraproc = thelock->intraproc;
1.11 +1 -4 apache-2.0/src/lib/apr/locks/unix/locks.h
Index: locks.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/locks.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- locks.h 2000/01/24 13:59:02 1.10
+++ locks.h 2000/01/25 23:04:27 1.11
@@ -112,12 +112,8 @@
char *fname;
#if USE_SYSVSEM_SERIALIZE
int interproc;
- struct sembuf op_on;
- struct sembuf op_off;
#elif USE_FCNTL_SERIALIZE
int interproc;
- struct flock lock_it;
- struct flock unlock_it;
#elif USE_PROC_PTHREAD_SERIALIZE
pthread_mutex_t *interproc;
#elif USE_FLOCK_SERIALIZE
@@ -144,6 +140,7 @@
ap_status_t destroy_intra_lock(struct lock_t *lock);
#endif
+void setup_lock();
ap_status_t create_inter_lock(struct lock_t *new);
ap_status_t lock_inter(struct lock_t *lock);
ap_status_t unlock_inter(struct lock_t *lock);
1.17 +3 -0 apache-2.0/src/lib/apr/misc/unix/start.c
Index: start.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/start.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- start.c 1999/12/22 20:29:19 1.16
+++ start.c 2000/01/25 23:04:39 1.17
@@ -54,6 +54,7 @@
*/
#include "misc.h"
+#include "../../locks/unix/locks.h"
/* ***APRDOC********************************************************
* ap_status_t ap_create_context(ap_context_t **, ap_context_t *)
@@ -187,6 +188,8 @@
ap_status_t ap_initialize(void)
{
sigset_t sigset;
+
+ setup_lock();
sigfillset(&sigset);
#if defined(HAVE_PTHREAD_SIGMASK) && defined(USE_THREADS)
1.7 +2 -0 apache-2.0/src/lib/apr/test/testthread.c
Index: testthread.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/test/testthread.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- testthread.c 1999/10/11 17:52:02 1.6
+++ testthread.c 2000/01/25 23:04:42 1.7
@@ -128,6 +128,8 @@
ap_status_t s3;
ap_status_t s4;
+ ap_initialize();
+
fprintf(stdout, "Initializing the context.......");
if (ap_create_context(&context, NULL) != APR_SUCCESS) {
fprintf(stderr, "could not initialize\n");