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 1999/05/10 19:57:56 UTC
cvs commit: apache-apr/apr/locks/unix Makefile crossproc.c intraproc.c locks.c locks.h
rbb 99/05/10 10:57:55
Added: apr/locks/unix Makefile crossproc.c intraproc.c locks.c
locks.h
Log:
First pass at the locking stuff.
Revision Changes Path
1.1 apache-apr/apr/locks/unix/Makefile
Index: Makefile
===================================================================
##
## Apache Makefile, automatically generated by Configure script.
## Hand-edited changes will be lost if the Configure script is re-run.
## Sources: - ../Makefile.config (via Configuration.apaci)
## - ./Makefile.tmpl
##
##
## Inherited Makefile options from Configure script
## (Begin of automatically generated section)
##
SRCDIR=..
EXTRA_CFLAGS=-g
EXTRA_LDFLAGS=
EXTRA_LIBS=-L ../../fileio -lfile
EXTRA_INCLUDES=
EXTRA_DEPS=
OSDIR=
INCDIR=../../../include
INCLUDES0=-I . -I $(INCDIR) -I ../../file_io/unix
SHELL=/bin/sh
CC=gcc
CPP=gcc -E
TARGET=
OPTIM=
CFLAGS_SHLIB=-fpic -DSHARED_MODULE
LD_SHLIB=ld
LDFLAGS_SHLIB=-Bshareable
LDFLAGS_SHLIB_EXPORT=-rdynamic
CFLAGS1= -DLINUX=2 -pthread -DUSE_HSREGEX
INCLUDES1=
LIBS_SHLIB=
LDFLAGS1=
MFLAGS_STATIC=--no-print-directory
REGLIB=regex/libregex.a
RANLIB=ranlib
LIBS1= -lm -lcrypt -lndbm -ldl
##
## (End of automatically generated section)
##
CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
LIBS=$(EXTRA_LIBS) $(LIBS1)
INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
LIB= libthreadproc.a
OBJS= locks.o crossproc.o intraproc.o
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $<
all: $(HEADERS) $(LIB)
$(LIB): $(OBJS)
rm -f $@
ar cr $@ $(OBJS)
$(RANLIB) $@
cp $@ ../
clean:
rm -f *.o $(LIB)
distclean: clean
-rm -f Makefile
# We really don't expect end users to use this rule. It works only with
# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after
# using it.
depend:
cp Makefile.tmpl Makefile.tmpl.bak \
&& sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
&& gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
&& sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
-e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
> Makefile.tmpl \
&& rm Makefile.new
#Dependencies
$(OBJS): Makefile
# DO NOT REMOVE
locks.o: locks.c
crossproc.o: crossproc.c
intraproc.o: intraproc.c
1.1 apache-apr/apr/locks/unix/crossproc.c
Index: crossproc.c
===================================================================
/* ====================================================================
* Copyright (c) 1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
#include "apr_lock.h"
#include "apr_general.h"
#include "locks.h"
#if defined (USE_SYSVSEM_SERIALIZE)
ap_status_t lock_cleanup(ap_lock_t *lock)
{
union semun ick;
if (lock->curr_locked == 1) {
ick.val = 0;
semctl(new->interproc, 0, IPC_RMID, ick);
}
return APR_SUCCESS;
}
ap_status_t create_inter_lock(ap_context_t *cont, ap_lock_t *new)
{
union semun ick;
struct semid_ds buf;
new->interproc = semget(IPC_PRIVATE, 1, IPC_CREATE | 0600);
if (new->interproc < 0) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
ick.val = 1;
if (senctl(new->interproc, 0, SETVAL, ick) < 0) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
/* pre-initialize 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(cont->pool, (void *)new, lock_cleanup, NULL);
return APR_SUCCESS;
}
ap_status_t lock_inter(ap_context_t *cont, ap_lock_t *lock)
{
new->curr_locked == 1;
if (semop(lock->interproc, &lock->op_on, 1) < 0) {
return(APR_FAILURE);
}
return APR_SUCCESS;
}
ap_status_t unlock_inter(ap_context_t *cont, ap_lock_t *lock)
{
if (semop(lock->interproc, &lock->op_off, 1) < 0) {
return(APR_FAILURE);
}
new->curr_locked == 0;
return APR_SUCCESS;
}
ap_status_t destroy_inter_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock_cleanup(lock) == APR_SUCCESS) {
ap_kill_cleanup(cont->pool, lock, lock_cleanup);
return APR_SUCCESS;
}
return APR_FAILURE;
}
#elif defined (USE_PTHREAD_SERIALIZE)
ap_status_t lock_cleanup(ap_lock_t *lock)
{
if (lock->curr_locked == 1) {
if (pthread_mutex_unlock(lock->interproc)) {
return APR_FAILURE;
}
if (munmap((caddr_t)lock->interproc, sizeof(pthread_mutex_t)){
return APR_FAILURE;
}
}
return APR_SUCCESS;
}
ap_status_t create_inter_lock(ap_context_t *cont, ap_lock_t *new)
{
int fd;
pthread_mutex_attr_t mattr;
fd = open("/dev/zero", O_RDWR);
if (fd < 0) {
return APR_FAILURE;
}
new->interproc = (pthread_mutex_t *)mmap((caddr_t) 0,
sizeof(pthread_mutex_t),
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (new->interproc = (void *) (caddr_t) -1) {
return APR_FAILURE;
}
close(fd);
if ((errno = pthread_mutexattr_init(&mattr))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
if ((errno = pthread_mutexattr_setpshared(&mattr,
PTHREAD_PROCESS_SHARED))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
if ((errno = pthread_mutex_init(new->interproc, &mattr))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
if ((errno = pthread_mutex_destroy(&mattr))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
new->curr_locked == 0;
ap_register_cleanup(cont->pool, (void *)new, lock_cleanup, NULL);
return APR_SUCCESS;
}
ap_status_t lock_inter(ap_context_t *cont, ap_lock_t *lock)
{
new->curr_locked == 1;
if (errno = pthread_mutex_lock(lock->interproc)) {
return(APR_FAILURE);
}
return APR_SUCCESS;
}
ap_status_t unlock_inter(ap_context_t *cont, ap_lock_t *lock)
{
if (errno = pthread_mutex_unlock(lock->interproc)) {
return(APR_FAILURE);
}
new->curr_locked == 0;
return APR_SUCCESS;
}
ap_status_t destroy_inter_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock_cleanup(lock) == APR_SUCCESS) {
ap_kill_cleanup(cont->pool, lock, lock_cleanup);
return APR_SUCCESS;
}
return APR_FAILURE;
}
#elif defined (USE_FCNTL_SERIALIZE)
ap_status_t lock_cleanup(ap_lock_t *lock)
{
if (lock->curr_locked == 1) {
if (fcntl(lock->interproc, F_SETLKW, &lock->unlock_it) < 0) {
return(APR_FAILURE);
}
new->curr_locked == 0;
}
return APR_SUCCESS;
}
ap_status_t create_inter_lock(ap_context_t *cont, ap_lock_t *new)
{
new->interproc = open(new->fname, O_CREATE | O_WRONLY | O_EXCL, 0644);
if (new->interproc < 0) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
/* pre-initialize 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);
ap_register_cleanup(cont->pool, (void *)new, lock_cleanup, NULL);
return APR_SUCCESS;
}
ap_status_t lock_inter(ap_context_t *cont, ap_lock_t *lock)
{
new->curr_locked == 1;
if (fcntl(lock->interproc, F_SETLKW, &lock->lock_it) < 0) {
return(APR_FAILURE);
}
return APR_SUCCESS;
}
ap_status_t unlock_inter(ap_context_t *cont, ap_lock_t *lock)
{
if (fcntl(lock->interproc, F_SETLKW, &lock->unlock_it) < 0) {
return(APR_FAILURE);
}
new->curr_locked == 0;
return APR_SUCCESS;
}
ap_status_t destroy_inter_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock_cleanup(lock) == APR_SUCCESS) {
ap_kill_cleanup(cont->pool, lock, lock_cleanup);
return APR_SUCCESS;
}
return APR_FAILURE;
}
#elif defined (USE_FLOCK_SERIALIZE)
ap_status_t lock_cleanup(ap_lock_t *lock)
{
if (lock->curr_locked == 1) {
if (flock(lock->interproc, LOCK_UN) < 0) {
return(APR_FAILURE);
}
new->curr_locked == 0;
}
unlink(lock->fname);
return APR_SUCCESS;
}
ap_status_t create_inter_lock(ap_context_t *cont, ap_lock_t *new)
{
new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0600);
if (new->interproc < 0) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
new->curr_locked == 0;
ap_register_cleanup(cont->pool, (void *)new, lock_cleanup, NULL);
return APR_SUCCESS;
}
ap_status_t lock_inter(ap_context_t *cont, ap_lock_t *lock)
{
new->curr_locked == 1;
if (flock(lock->interproc, LOCK_EX) < 0) {
return(APR_FAILURE);
}
return APR_SUCCESS;
}
ap_status_t unlock_inter(ap_context_t *cont, ap_lock_t *lock)
{
if (flock(lock->interproc, LOCK_UN) < 0) {
return(APR_FAILURE);
}
new->curr_locked == 0;
return APR_SUCCESS;
}
ap_status_t destroy_inter_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock_cleanup(lock) == APR_SUCCESS) {
ap_kill_cleanup(cont->pool, lock, lock_cleanup);
return APR_SUCCESS;
}
return APR_FAILURE;
}
#else
/* No inter-process mutex on this platform. Use at your own risk */
#define create_inter_lock(x, y)
#define lock_inter(x, y)
#define unlock_inter(x, y)
#define destroy_inter_lock(x, y)
#endif
1.1 apache-apr/apr/locks/unix/intraproc.c
Index: intraproc.c
===================================================================
/* ====================================================================
* Copyright (c) 1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
#include "apr_lock.h"
#include "apr_general.h"
#include "locks.h"
#if defined (USE_PTHREAD_SERIALIZE)
ap_status_t lock_cleanup(ap_lock_t *lock)
{
if (lock->curr_locked == 1) {
if (pthread_mutex_unlock(lock->interproc)) {
return APR_FAILURE;
}
}
return APR_SUCCESS;
}
ap_status_t create_inter_lock(ap_context_t *cont, ap_lock_t *new)
{
int fd;
pthread_mutex_attr_t mattr;
fd = open("/dev/zero", O_RDWR);
if (fd < 0) {
return APR_FAILURE;
}
new->interproc = (pthread_mutex_t *)ap_palloc(cont->pool,
sizeof(pthread_mutex_t));
if (new->interproc = (void *) (caddr_t) -1) {
return APR_FAILURE;
}
close(fd);
if ((errno = pthread_mutexattr_init(&mattr))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
if ((errno = pthread_mutex_init(new->interproc, &mattr))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
if ((errno = pthread_mutex_destroy(&mattr))) {
lock_cleanup(cont, new);
return APR_FAILURE;
}
new->curr_locked == 0;
ap_register_cleanup(cont->pool, (void *)new, lock_cleanup, NULL);
return APR_SUCCESS;
}
ap_status_t lock_inter(ap_context_t *cont, ap_lock_t *lock)
{
new->curr_locked == 1;
if (errno = pthread_mutex_lock(lock->interproc)) {
return(APR_FAILURE);
}
return APR_SUCCESS;
}
ap_status_t unlock_inter(ap_context_t *cont, ap_lock_t *lock)
{
if (errno = pthread_mutex_unlock(lock->interproc)) {
return(APR_FAILURE);
}
new->curr_locked == 0;
return APR_SUCCESS;
}
ap_status_t destroy_inter_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock_cleanup(lock) == APR_SUCCESS) {
ap_kill_cleanup(cont->pool, lock, lock_cleanup);
return APR_SUCCESS;
}
return APR_FAILURE;
}
#endif
1.1 apache-apr/apr/locks/unix/locks.c
Index: locks.c
===================================================================
/* ====================================================================
* Copyright (c) 1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
#include "apr_lock.h"
#include "apr_general.h"
#include "locks.h"
#include <strings.h>
ap_lock_t *ap_create_lock(ap_context_t *cont, ap_locktype_e type, char *fname)
{
ap_lock_t *new;
new = (ap_lock_t *)ap_palloc(cont->pool, sizeof(ap_lock_t));
new->type = type;
new->fname = strdup(fname);
if (type != APR_CROSS_PROCESS) {
if (create_intra_lock(cont, new) == APR_FAILURE) {
return NULL;
}
}
if (type != APR_INTRAPROCESS) {
if (create_inter_lock(cont, new) == APR_FAILURE) {
return NULL;
}
}
return new;
}
ap_status_t ap_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock->type != APR_CROSS_PROCESS) {
if (lock_intra(cont, lock) == APR_FAILURE) {
return APR_FAILURE;
}
}
if (lock->type != APR_INTRAPROCESS) {
if (lock_inter(cont, lock) == APR_FAILURE) {
return APR_FAILURE;
}
}
return APR_SUCCESS;
}
ap_status_t ap_unlock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock->type != APR_CROSS_PROCESS) {
if (unlock_intra(cont, lock) == APR_FAILURE) {
return APR_FAILURE;
}
}
if (lock->type != APR_INTRAPROCESS) {
if (unlock_inter(cont, lock) == APR_FAILURE) {
return APR_FAILURE;
}
}
return APR_SUCCESS;
}
ap_status_t ap_destroy_lock(ap_context_t *cont, ap_lock_t *lock)
{
if (lock->type != APR_CROSS_PROCESS) {
if (destroy_intra_lock(cont, lock) == APR_FAILURE) {
return APR_FAILURE;
}
}
if (lock->type != APR_INTRAPROCESS) {
if (destroy_inter_lock(cont, lock) == APR_FAILURE) {
return APR_FAILURE;
}
}
return APR_SUCCESS;
}
1.1 apache-apr/apr/locks/unix/locks.h
Index: locks.h
===================================================================
/* ====================================================================
* Copyright (c) 1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
#ifndef LOCKS_H
#define LOCKS_H
#include "apr_lock.h"
#include "apr_file_io.h"
#if defined (USE_USLOCK_SERIALIZE)
#include <uslocks.h>
#elif defined (USE_SYSVSEM_SERIALIZE)
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#endif
#include <pthread.h>
#ifdef NEED_UNION_SEMUN
/* it makes no sense, but this isn't defined on solaris */
union semun {
long val;
struct semid_ds *buf;
ushort *array;
};
#endif
struct lock_t {
ap_locktype_e type;
int curr_locked;
char *fname;
#if defined (USE_SYSVSEM_SERIALIZE)
int interproc;
struct sembuf op_on;
struct sembuf op_off;
#elif defined (USE_FCNTL_SERIALIZE)
int interproc;
struct flock lock_it;
struct flock unlock_it;
#elif defined (USE_PTHREAD_MUTEX)
pthread_mutex_t *intraproc;
#elif defined (USE_FLOCK_SERIALIZE)
int interproc;
#else
/* No Interprocess serialization. Too bad. */
#endif
pthread_mutex_t *intraproc;
/* At some point, we should do a type for both inter and intra process
* locking here. Something like pthread_mutex with PTHREAD_PROCESS_SHARED
*/
};
#endif /* LOCKS_H */