From: Jim Jagielski Date: Thu, 17 Jan 2002 13:20:51 +0000 (+0000) Subject: PR: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08caa9c84ad17e7bdfbbdcfaac34ab035c598f76;p=thirdparty%2Fapache%2Fhttpd.git PR: Obtained from: Submitted by: Stipe Tolj Reviewed by: Add in Stipe's Cygwin changes.... Have not folded in the Cygwin timeout kill signaling patch yet... waiting for feedback. Here are the changes: * src/include/ap_config.h: adding HAVE_PTHREAD_SERIALIZED_ACCEPT to Cygwin block and defaulting to it. * src/main/http_main.c: exluding pthread_mutexattr_setpshared() call for Cygwin platform. This calls seems yet not fully functional on this platform. Forwarding problem to Cygwin core developers. * src/Configure: changed OS_MODULE_INCLUDE var for the Cygwin platform block to refer to the (absolute) relative path for the Makefile.Cygwin file. * src/modules/proxy/Makefile.tmpl: target libproxy.dll is hardcoded for OS/2. That's not good. We have the same target on Cygwin, but use other calls for it, so if construct here. * src/modules/standard/Makefile.Cygwin: adding a dummy target %.def : %.c to satisfy OS/2 related dependacies on Cygwin too. Changed the "run make twice" screen slightly. * src/Configuration.tmpl: added rule CYGWIN_WINSOCK=no * src/Configure: added loading of rule CYGWIN_WINSOCK and Cygwin platform block specific if statement to include libwsock32.a lib for Cygwin. * src/main/buff.c: added a couple of #define add-ons for CYGWIN_WINSOCK * src/main/http_main.c: added two #defines for CYGWIN_WINSOCK and compilation flag information output if set at configure time. * src/os/cygwin/os.h: added required #defines for CYGWIN_WINSOCK and declarations for Win32 native calls. Also a patch against current 1.3 cvs tree to fix the detection of the gdbm library for the Cygwin platform to support dbm-enabled mod_rewrite. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@92888 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index 188dc086006..5659c6bcb5c 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,13 @@ Changes with Apache 1.3.23 + *) PORT: Numerous additions to Cygwin, including: defaulting + to Posix thread accept mutex, excluding the call to + pthread_mutexattr_setpshared(), better proxy and DBM support, and + allowing the use of native Win32 socket ops instead of + Cygwin's Posix wrapper (for better performance). The last + item required the addition of a new Configure Rule: CYGWIN_WINSOCK. + [Stipe Tolj ] + *) Use "httpready" accept filter rather than "dataready" on FreeBSD after 4.1.1-RELEASE where it works correctly. [Tony Finch] diff --git a/src/Configuration.tmpl b/src/Configuration.tmpl index 9ee79f94b36..7ec60b640d0 100644 --- a/src/Configuration.tmpl +++ b/src/Configuration.tmpl @@ -173,6 +173,13 @@ Rule SHARED_CHAIN=default # Rule EXPAT=default : If Expat can be found at the system or # in lib/expat-lite, use it; otherwise # skip it +# +# CYGWIN_WINSOCK: +# Use Win32 API system calls for socket communication instead +# of Cygwin's POSIX.1 wrappers. This avoids the Cygwin specific +# implementation and uses the Win32 native calls. Should be faster +# and more reliable for high-load systems. +# Rule SOCKS4=no Rule SOCKS5=no @@ -180,6 +187,7 @@ Rule IRIXNIS=no Rule IRIXN32=yes Rule PARANOID=no Rule EXPAT=default +Rule CYGWIN_WINSOCK=no # DEV_RANDOM: # Note: this rule is only used when compiling mod_auth_digest. diff --git a/src/Configure b/src/Configure index 94289ce44f0..11c4e941e83 100755 --- a/src/Configure +++ b/src/Configure @@ -235,6 +235,7 @@ RULE_IRIXNIS=`./helpers/CutRule IRIXNIS $file` RULE_IRIXN32=`./helpers/CutRule IRIXN32 $file` RULE_PARANOID=`./helpers/CutRule PARANOID $file` RULE_EXPAT=`./helpers/CutRule EXPAT $file` +RULE_CYGWIN_WINSOCK=`./helpers/CutRule CYGWIN_WINSOCK $file` RULE_SHARED_CORE=`./helpers/CutRule SHARED_CORE $file` RULE_SHARED_CHAIN=`./helpers/CutRule SHARED_CHAIN $file` @@ -849,6 +850,11 @@ case "$PLAT" in DEF_WANTHSREGEX=yes DBM_LIB="-lgdbm" LIBS="$LIBS -lcrypt $DBM_LIB" + if [ "x$RULE_CYGWIN_WINSOCK" = "xyes" ]; then + CFLAGS="$CFLAGS -DCYGWIN_WINSOCK" + LIBS="$LIBS -lwsock32" + fi + ;; *atheos*) DEF_WANTSREGEX=yes @@ -1419,7 +1425,7 @@ if [ "x$using_shlib" = "x1" ] ; then LIBS_SHLIB='$(EXTRA_LIBS)' SHARED_CORE_EP='lib$(TARGET).ep' SHCORE_IMPLIB='lib$(TARGET).dll' - OS_MODULE_INCLUDE='Makefile.Cygwin' + OS_MODULE_INCLUDE='$(SRCDIR)/modules/standard/Makefile.Cygwin' ;; *) ## ok, no known explict support for shared objects diff --git a/src/helpers/find-dbm-lib b/src/helpers/find-dbm-lib index 4ec265b326c..5f66b4aba32 100644 --- a/src/helpers/find-dbm-lib +++ b/src/helpers/find-dbm-lib @@ -31,6 +31,15 @@ if [ "x$found_dbm" = "x" ]; then found_dbm=1 fi ;; + *-cygwin*) + # we use the shared DLL version of gdbm if available + DBM_LIB="" + if ./helpers/TestCompile lib gdbm dbm_open; then + DBM_LIB="-lgdbm" + LIBS="$LIBS $DBM_LIB" + found_dbm=1 + fi + ;; *) if [ "x$DBM_LIB" != "x" ]; then oldLIBS="$LIBS" diff --git a/src/include/ap_config.h b/src/include/ap_config.h index daeccae7657..0a956b1a636 100644 --- a/src/include/ap_config.h +++ b/src/include/ap_config.h @@ -1012,7 +1012,11 @@ typedef int rlim_t; #define USE_MMAP_FILES #define HAVE_SYSLOG 1 #define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_PTHREAD_SERIALIZED_ACCEPT #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#if !defined(USE_FNCTL_SERIALIZED_ACCEPT) +#define USE_PTHREAD_SERIALIZED_ACCEPT +#endif #else diff --git a/src/main/buff.c b/src/main/buff.c index b2bb81f37f8..55346597c68 100644 --- a/src/main/buff.c +++ b/src/main/buff.c @@ -122,7 +122,7 @@ * futher I/O will be done */ -#if defined(WIN32) || defined(NETWARE) +#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) /* select() sometimes returns 1 even though the write will block. We must work around this. @@ -282,7 +282,7 @@ static ap_inline int buff_read(BUFF *fb, void *buf, int nbyte) { int rv; -#if defined (WIN32) || defined(NETWARE) +#if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) if (fb->flags & B_SOCKET) { rv = recvwithtimeout(fb->fd_in, buf, nbyte, 0); if (rv == SOCKET_ERROR) @@ -1477,7 +1477,7 @@ API_EXPORT(int) ap_bclose(BUFF *fb) rc1 = ap_bflush(fb); else rc1 = 0; -#if defined(WIN32) || defined(NETWARE) +#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) if (fb->flags & B_SOCKET) { rc2 = ap_pclosesocket(fb->pool, fb->fd); if (fb->fd_in != fb->fd) { @@ -1487,7 +1487,7 @@ API_EXPORT(int) ap_bclose(BUFF *fb) rc3 = 0; } } -#ifndef NETWARE +#if !defined(NETWARE) && !defined(CYGWIN_WINSOCK) else if (fb->hFH != INVALID_HANDLE_VALUE) { rc2 = ap_pcloseh(fb->pool, fb->hFH); rc3 = 0; @@ -1512,7 +1512,7 @@ API_EXPORT(int) ap_bclose(BUFF *fb) else { rc3 = 0; } -#if defined(WIN32) || defined (BEOS) || defined(NETWARE) +#if defined(WIN32) || defined (BEOS) || defined(NETWARE) || defined(CYGWIN_WINSOCK) } #endif diff --git a/src/main/http_main.c b/src/main/http_main.c index 14ed577e58b..debb1fb752a 100644 --- a/src/main/http_main.c +++ b/src/main/http_main.c @@ -662,11 +662,16 @@ static void accept_mutex_init_pthread(pool *p) perror("pthread_mutexattr_init"); exit(APEXIT_INIT); } +#if !defined(CYGWIN) + /* Cygwin has problems with this pthread call claiming that these + * are "Invalid arguements", Stipe Tolj + */ if ((errno = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED))) { perror("pthread_mutexattr_setpshared"); exit(APEXIT_INIT); } +#endif if ((errno = pthread_mutex_init(accept_mutex, &mattr))) { perror("pthread_mutex_init"); exit(APEXIT_INIT); @@ -1564,7 +1569,7 @@ API_EXPORT(void) ap_unblock_alarms(void) #ifndef NETWARE static APACHE_TLS void (*volatile alarm_fn) (int) = NULL; #endif -#ifdef WIN32 +#if defined(WIN32) || defined(CYGWIN_WINSOCK) static APACHE_TLS unsigned int alarm_expiry_time = 0; #endif /* WIN32 */ @@ -1624,7 +1629,7 @@ API_EXPORT_NONSTD(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int } -#if defined(WIN32) || defined(NETWARE) +#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) API_EXPORT(int) ap_check_alarm(void) { #ifdef NETWARE @@ -4067,6 +4072,9 @@ static void show_compile_settings(void) #ifdef AP_ACCEPTFILTER_OFF printf(" -D AP_ACCEPTFILTER_OFF\n"); #endif +#ifdef CYGWIN_WINSOCK + printf(" -D CYGWIN_WINSOCK\n"); +#endif /* This list displays the compiled-in default paths: */ #ifdef HTTPD_ROOT diff --git a/src/modules/proxy/Makefile.tmpl b/src/modules/proxy/Makefile.tmpl index 07dfb7eedf6..f721914b57c 100644 --- a/src/modules/proxy/Makefile.tmpl +++ b/src/modules/proxy/Makefile.tmpl @@ -21,10 +21,18 @@ libproxy.so: $(OBJS_PIC) rm -f $@ $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(OBJS_PIC) $(LIBS_SHLIB) -libproxy.dll: $(OBJS_PIC) mod_proxy.def - $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $* $(OBJS_PIC) $(LIBS_SHLIB) - emxbind -b -q -s -h0 -dmod_proxy.def $* && \ - rm $* +libproxy.dll: $(OBJS_PIC) mod_proxy.def + if [ "x$(OS)" = "xCygwin" ]; then \ + rm -f $@; \ + if [ -f "$(SRCDIR)/$(SHCORE_IMPLIB)" ]; then \ + $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $*.dll $(OBJS_PIC) $(LIBS_SHLIB) \ + $(SRCDIR)/$(SHCORE_IMPLIB) $(LIBS1); \ + fi \ + else \ + $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $* $(OBJS_PIC) $(LIBS_SHLIB); \ + emxbind -b -q -s -h0 -dmod_proxy.def $* && \ + rm $*; \ + fi .SUFFIXES: .o .lo .dll diff --git a/src/modules/standard/Makefile.Cygwin b/src/modules/standard/Makefile.Cygwin index af4d5e27542..61ac32af916 100644 --- a/src/modules/standard/Makefile.Cygwin +++ b/src/modules/standard/Makefile.Cygwin @@ -28,23 +28,30 @@ define shared_dll $(SRCDIR)/$(SHCORE_IMPLIB) $(LIBS1) endef +%.def : %.c + touch $*.def + %.lo : %.c $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $< && mv $*.o $*.lo %.dll : %.lo @if [ -f "$(SRCDIR)/$(SHCORE_IMPLIB)" ]; then \ + rm -f $(SRCDIR)/$(SHCORE_IMPLIB).$$; \ echo $(shared_dll); \ $(shared_dll); \ else \ - echo "+--------------------------------------------------------+"; \ - echo "| There is no shared core 'libhttpd.dll' available! |"; \ - echo "| |"; \ - echo "| This is obviously your first 'make' run with configure |"; \ - echo "| flag SHARED_CORE enabled and shared modules. |"; \ - echo "| |"; \ - echo "| You will have to re-run 'make' after this run builds |"; \ - echo "| the required shared import library! |"; \ - echo "+--------------------------------------------------------+"; \ - sleep 10; \ + if [ ! -f "$(SRCDIR)/$(SHCORE_IMPLIB).$$" ]; then \ + echo "+--------------------------------------------------------+"; \ + echo "| There is no shared core 'libhttpd.dll' available! |"; \ + echo "| |"; \ + echo "| This is obviously your first 'make' run with configure |"; \ + echo "| flag SHARED_CORE enabled and shared modules. |"; \ + echo "| |"; \ + echo "| You will have to re-run 'make' after this run builds |"; \ + echo "| the required shared import library! |"; \ + echo "+--------------------------------------------------------+"; \ + sleep 10; \ + touch $(SRCDIR)/$(SHCORE_IMPLIB).$$; \ + fi; \ fi; diff --git a/src/os/cygwin/os.h b/src/os/cygwin/os.h index 133d9244e53..3a0d7e01bb3 100644 --- a/src/os/cygwin/os.h +++ b/src/os/cygwin/os.h @@ -88,6 +88,25 @@ #define PLATFORM "Cygwin" #endif +/* + * Define winsock.h and winsock2.h stuff taken from Win32 API in case we + * want to do socket communication in Win32 native way rather then using + * Cygwin's POSIX wrapper to the native ones. These are needed for + * main/buff.c and main/http_main.c. They are linked against libwsock32.a + * for the import declarations of the corresponding Win32 native DLLs. + */ +#ifdef CYGWIN_WINSOCK +#define WSAEWOULDBLOCK (10035) +#define SOCKET_ERROR (-1) + +#define WIN32API_IMPORT(type) __declspec(dllimport) type __stdcall + +WIN32API_IMPORT(int) WSAGetLastError(void); +WIN32API_IMPORT(int) WSASetLastError(int); +WIN32API_IMPORT(int) ioctlsocket(unsigned int, long, unsigned long *); +WIN32API_IMPORT(void) Sleep(unsigned int); +#endif /* CYGWIN_WINSOCK */ + /* * This file in included in all Apache source code. It contains definitions * of facilities available on _this_ operating system (HAVE_* macros),