diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2004-06-14 08:53:31 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2004-06-14 08:53:31 +0000 |
commit | eb2255812ef749f866ab2be663505d4558adef05 (patch) | |
tree | a8114a7b736043e6b14d18ed24f8eb65c20b0cb1 | |
parent | f2ad8701668b17c381f2af7da9ea30d32791fcb6 (diff) | |
download | libapr-eb2255812ef749f866ab2be663505d4558adef05.tar.gz |
Support POSIX semaphores on LP64 platforms:
* configure.in: Don't disable POSIX semaphore support on LP64
platforms.
* include/arch/unix/apr_arch_proc_mutex.h (struct apr_proc_mutex_t):
Add a sem_t pointer field.
* locks/unix/proc_mutex.c (proc_mutex_posix_create,
proc_mutex_posix_cleanup, proc_mutex_posix_acquire,
prox_mutex_posix_release): Use the sem_t pointer not the fd for the
semaphore.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65185 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | include/arch/unix/apr_arch_proc_mutex.h | 3 | ||||
-rw-r--r-- | locks/unix/proc_mutex.c | 8 |
3 files changed, 7 insertions, 6 deletions
diff --git a/configure.in b/configure.in index 01f600490..01871721c 100644 --- a/configure.in +++ b/configure.in @@ -1492,8 +1492,6 @@ main() sem_t *psem; const char *sem_name = "/apr_autoconf"; - if (sizeof(int) < sizeof(sem_t *)) - exit(1); psem = sem_open(sem_name, O_CREAT, 0644, 1); if (psem == (sem_t *)SEM_FAILED) { exit(1); diff --git a/include/arch/unix/apr_arch_proc_mutex.h b/include/arch/unix/apr_arch_proc_mutex.h index 40dcc7e1f..1a3a4fc01 100644 --- a/include/arch/unix/apr_arch_proc_mutex.h +++ b/include/arch/unix/apr_arch_proc_mutex.h @@ -98,6 +98,9 @@ struct apr_proc_mutex_t { #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE apr_file_t *interproc; #endif +#if APR_HAS_POSIXSEM_SERIALIZE + sem_t *psem_interproc; +#endif #if APR_HAS_PROC_PTHREAD_SERIALIZE pthread_mutex_t *pthread_interproc; #endif diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c index a401f15fc..9d1c90b63 100644 --- a/locks/unix/proc_mutex.c +++ b/locks/unix/proc_mutex.c @@ -50,7 +50,7 @@ static apr_status_t proc_mutex_posix_cleanup(void *mutex_) apr_status_t stat = APR_SUCCESS; if (mutex->interproc->filedes != -1) { - if (sem_close((sem_t *)mutex->interproc->filedes) < 0) { + if (sem_close(mutex->psem_interproc) < 0) { stat = errno; } } @@ -113,7 +113,7 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex, } /* Ahhh. The joys of Posix sems. Predelete it... */ sem_unlink((const char *) semname); - new_mutex->interproc->filedes = (int)psem; /* Ugg */ + new_mutex->psem_interproc = psem; new_mutex->fname = apr_pstrdup(new_mutex->pool, semname); apr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex, apr_proc_mutex_cleanup, @@ -125,7 +125,7 @@ static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex) { int rc; - if ((rc = sem_wait((sem_t *)mutex->interproc->filedes)) < 0) { + if ((rc = sem_wait(mutex->psem_interproc)) < 0) { return errno; } mutex->curr_locked = 1; @@ -137,7 +137,7 @@ static apr_status_t proc_mutex_posix_release(apr_proc_mutex_t *mutex) int rc; mutex->curr_locked = 0; - if ((rc = sem_post((sem_t *)mutex->interproc->filedes)) < 0) { + if ((rc = sem_post(mutex->psem_interproc)) < 0) { return errno; } return APR_SUCCESS; |