rbb 99/06/30 12:46:00
Modified: apr Makefile.in configure.in apr/include apr_config.h.in apr_win.h apr/misc/unix Makefile.in start.c apr/signal/win32 signal.c signal.def apr/test Makefile.in testsig.c include apr_general.h Added: apr/signal/unix Makefile.in signal.c Log: First pass at signals on Unix. This only works if you have pthreads, but making it work everywhere is trivial. Revision Changes Path 1.11 +1 -1 apache-apr/apr/Makefile.in Index: Makefile.in =================================================================== RCS file: /home/cvs/apache-apr/apr/Makefile.in,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Makefile.in 1999/06/16 19:13:45 1.10 +++ Makefile.in 1999/06/30 19:45:30 1.11 @@ -24,7 +24,7 @@ # MODULES=lib file_io network_io threadproc locks misc time SUBDIRS=lib file_io/@OSDIR@ network_io/@OSDIR@ threadproc/@OSDIR@ \ - locks/@OSDIR@ misc/@OSDIR@ time/@OSDIR@ + locks/@OSDIR@ misc/@OSDIR@ time/@OSDIR@ signal/@OSDIR@ # # Rules for turning inputs into outputs 1.23 +3 -1 apache-apr/apr/configure.in Index: configure.in =================================================================== RCS file: /home/cvs/apache-apr/apr/configure.in,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- configure.in 1999/06/17 15:05:17 1.22 +++ configure.in 1999/06/30 19:45:31 1.23 @@ -155,6 +155,8 @@ AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/wait.h) +AC_CHECK_HEADERS(pthread.h) + dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T @@ -177,4 +179,4 @@ AC_OUTPUT(Makefile lib/Makefile file_io/$OSDIR/Makefile network_io/$OSDIR/Makefile threadproc/$OSDIR/Makefile locks/$OSDIR/Makefile misc/$OSDIR/Makefile - time/$OSDIR/Makefile test/Makefile) + time/$OSDIR/Makefile signal/$OSDIR/Makefile test/Makefile) 1.10 +2 -0 apache-apr/apr/include/apr_config.h.in Index: apr_config.h.in =================================================================== RCS file: /home/cvs/apache-apr/apr/include/apr_config.h.in,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- apr_config.h.in 1999/06/21 18:28:10 1.9 +++ apr_config.h.in 1999/06/30 19:45:35 1.10 @@ -66,6 +66,8 @@ #undef HAVE_SYS_TYPES_H #undef HAVE_SYS_WAIT_H +#undef HAVE_PTHREAD_H + /* * List of features/library functions available, which we'll use if * they're compatible. 1.6 +0 -1 apache-apr/apr/include/apr_win.h Index: apr_win.h =================================================================== RCS file: /home/cvs/apache-apr/apr/include/apr_win.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- apr_win.h 1999/06/29 15:52:07 1.5 +++ apr_win.h 1999/06/30 19:45:36 1.6 @@ -100,7 +100,6 @@ typedef _off_t off_t; typedef int pid_t; typedef void (Sigfunc)(int); -typedef int ap_signum_t; #define __attribute__(__x) #define APR_INLINE 1.5 +3 -3 apache-apr/apr/misc/unix/Makefile.in Index: Makefile.in =================================================================== RCS file: /home/cvs/apache-apr/apr/misc/unix/Makefile.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Makefile.in 1999/06/15 19:43:39 1.4 +++ Makefile.in 1999/06/30 19:45:39 1.5 @@ -52,6 +52,6 @@ # DO NOT REMOVE start.o: start.c ../../../include/apr_general.h \ - ../../../include/apr_errno.h ../../include/apr_pools.h \ - ../../include/apr_lib.h ../../include/apr_config.h \ - ../../include/hsregex.h + $(INCDIR)/apr_config.h ../../../include/apr_errno.h \ + $(INCDIR)/apr_pools.h $(INCDIR)/apr_lib.h \ + $(INCDIR)/hsregex.h misc.h ../../../include/apr_file_io.h 1.8 +11 -0 apache-apr/apr/misc/unix/start.c Index: start.c =================================================================== RCS file: /home/cvs/apache-apr/apr/misc/unix/start.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- start.c 1999/06/21 17:45:55 1.7 +++ start.c 1999/06/30 19:45:39 1.8 @@ -57,6 +57,7 @@ #include "apr_errno.h" #include "apr_pools.h" #include "misc.h" +#include <pthread.h> #include <errno.h> #include <string.h> @@ -145,3 +146,13 @@ return APR_ENOCONT; } +#ifdef HAVE_PTHREAD_H +ap_status_t ap_initialize(void) +{ + sigset_t sigset; + + sigfillset(&sigset); + pthread_sigmask(SIG_BLOCK, &sigset, NULL); +} +#endif + 1.1 apache-apr/apr/signal/unix/Makefile.in Index: Makefile.in =================================================================== #CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) #LIBS=$(EXTRA_LIBS) $(LIBS1) #INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) #LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ @CFLAGS@ @OPTIM@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ $(LDLIBS) INCDIR=../../include INCDIR1=../../../include INCDIR2=../../file_io/unix INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I. LIB=../libsig.a OBJS=signal.o \ .c.o: $(CC) $(CFLAGS) -c $(INCLUDES) $< all: $(LIB) clean: $(RM) -f *.o *.a *.so distclean: clean -$(RM) -f Makefile $(OBJS): Makefile $(LIB): $(OBJS) $(RM) -f $@ $(AR) cr $@ $(OBJS) $(RANLIB) $@ # # 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.in Makefile.in.bak \ && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > 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.in \ && rm Makefile.new # DO NOT REMOVE 1.1 apache-apr/apr/signal/unix/signal.c Index: signal.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 * [EMAIL PROTECTED] * * 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_general.h" #include <string.h> #ifdef HAVE_PTHREAD_H ap_status_t ap_create_signal(ap_context_t *cont, ap_signum_t signum) { return APR_SUCCESS; } /* Signals can only be sent to the whole process group because I havne't * figured out how to send to individual children on Winodws yet. When * that is solved, this will change here. */ ap_status_t ap_send_signal(ap_context_t *cont, ap_signum_t signum) { killpg(0, signum); return APR_SUCCESS; } ap_setup_signal(ap_context_t *cont, ap_signum_t signum, Sigfunc *func) { sigset_t newset; sigemptyset(&newset); sigaddset(&newset, signum); signal(signum, func); pthread_sigmask(SIG_UNBLOCK, &newset, NULL); return APR_SUCCESS; } #endif 1.2 +2 -2 apache-apr/apr/signal/win32/signal.c Index: signal.c =================================================================== RCS file: /home/cvs/apache-apr/apr/signal/win32/signal.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- signal.c 1999/06/29 15:52:10 1.1 +++ signal.c 1999/06/30 19:45:44 1.2 @@ -89,7 +89,7 @@ return APR_SUCCESS; } -ap_status_t ap_signal(ap_context_t *cont, ap_signum_t signum) +ap_status_t ap_send_signal(ap_context_t *cont, ap_signum_t signum) { HANDLE event; char *EventName; @@ -179,4 +179,4 @@ int thread_ready(void) { return ready; -} \ No newline at end of file +} 1.2 +1 -1 apache-apr/apr/signal/win32/signal.def Index: signal.def =================================================================== RCS file: /home/cvs/apache-apr/apr/signal/win32/signal.def,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- signal.def 1999/06/29 15:52:10 1.1 +++ signal.def 1999/06/30 19:45:45 1.2 @@ -8,5 +8,5 @@ ap_create_signal @1 ap_setup_signal @2 SignalHandling @3 - ap_signal @4 + ap_send_signal @4 thread_ready @5 1.11 +8 -3 apache-apr/apr/test/Makefile.in Index: Makefile.in =================================================================== RCS file: /home/cvs/apache-apr/apr/test/Makefile.in,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Makefile.in 1999/06/15 19:43:46 1.10 +++ Makefile.in 1999/06/30 19:45:50 1.11 @@ -8,7 +8,7 @@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ @CFLAGS@ @OPTIM@ -LDLIBS=-L../network_io -lnetwork -L../threadproc -lthreadproc -L../file_io -lfile -L../misc -lmisc -L../lib -lapr -L../time -ltime -L../locks -llock @LDLIBS@ +LDLIBS=-L../network_io -lnetwork -L../threadproc -lthreadproc -L../file_io -lfile -L../misc -lmisc -L../lib -lapr -L../time -ltime -L../locks -llock -L../signal -lsig @LDLIBS@ [EMAIL PROTECTED]@ $(LDLIBS) INCDIR=../include INCDIR1=../../include @@ -19,14 +19,16 @@ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ \ - [EMAIL PROTECTED]@ + [EMAIL PROTECTED]@ \ + [EMAIL PROTECTED]@ OBJS= testfile.o \ testproc.o \ testsock.o \ testthread.o \ ab_apr.o \ - testtime.o + testtime.o \ + testsig.o .c.o: $(CC) -c $(CFLAGS) $(INCLUDES) $< @@ -52,6 +54,9 @@ [EMAIL PROTECTED]@: testtime.o $(CC) $(CFLAGS) testtime.o -o [EMAIL PROTECTED]@ $(LDFLAGS) + [EMAIL PROTECTED]@: testsig.o + $(CC) $(CFLAGS) testsig.o -o [EMAIL PROTECTED]@ $(LDFLAGS) clean: $(RM) -f *.o *.a *.so $(TARGETS) 1.2 +4 -6 apache-apr/apr/test/testsig.c Index: testsig.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testsig.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- testsig.c 1999/06/29 15:52:11 1.1 +++ testsig.c 1999/06/30 19:45:51 1.2 @@ -86,13 +86,12 @@ if (argc > 1) { - ap_setup_signal(context, APR_SIGHUP, hup_handler); while(time_to_die == 0) { sleep(1); } - return (1); + return(1); } fprintf(stdout, "Creating new signal......."); @@ -112,15 +111,14 @@ args[1] = ap_pstrdup(context, "-X"); args[2] = NULL; - if (ap_create_process(context, "../testproc", args, NULL, attr, &newproc) != APR_SUCCESS) { + if (ap_create_process(context, "./testsig", args, NULL, attr, &newproc) != APR_SUCCESS) { fprintf(stderr, "Could not create the new process\n"); exit(-1); } -/* sleep(100); /* Just wait a bit to let the child catch up. Not a great idea, but - * this is just a test program, so it's okay in my book. :) */ fprintf(stdout, "Sending the signal......."); - ap_signal(context, APR_SIGHUP); + fflush(stdout); + ap_send_signal(context, APR_SIGHUP); ap_wait_proc(newproc, APR_WAIT); 1.20 +2 -1 apache-apr/include/apr_general.h Index: apr_general.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_general.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- apr_general.h 1999/06/29 15:52:14 1.19 +++ apr_general.h 1999/06/30 19:45:58 1.20 @@ -108,6 +108,7 @@ #endif typedef struct context_t ap_context_t; +typedef int ap_signum_t; #if SIGHUP #define APR_SIGHUP SIGHUP @@ -210,7 +211,7 @@ ap_status_t ap_initialize(void); ap_status_t ap_create_signal(ap_context_t *, ap_signum_t); -ap_status_t ap_signal(ap_context_t *, ap_signum_t); +ap_status_t ap_send_signal(ap_context_t *, ap_signum_t); ap_status_t ap_setup_signal(ap_context_t *, ap_signum_t, Sigfunc *); #ifdef __cplusplus