The attached patch introduces a new rule to src/Configuration.tmpl called CYGWIN_WINSOCK. It may be used for the Cygwin 1.x platform to use the native Win32 calls for the socket operations instead of Cygwin's own POSIX.1 wrappers.
A performance gain of about 5-10% has been detected if used. Here are the changes: * 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. Stipe [EMAIL PROTECTED] ------------------------------------------------------------------- Wapme Systems AG Münsterstr. 248 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [EMAIL PROTECTED] Internet: http://www.wapme-systems.de ------------------------------------------------------------------- wapme.net - wherever you are
diff -ur apache-1.3/src/Configuration.tmpl apache-1.3-cygwin/src/Configuration.tmpl --- apache-1.3/src/Configuration.tmpl Mon Oct 8 17:52:12 2001 +++ apache-1.3-cygwin/src/Configuration.tmpl Sat Nov 10 16:48:46 2001 @@ -173,6 +173,13 @@ # 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 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 -ur apache-1.3/src/Configure apache-1.3-cygwin/src/Configure --- apache-1.3/src/Configure Mon Oct 8 20:59:36 2001 +++ apache-1.3-cygwin/src/Configure Thu Dec 13 21:11:10 2001 @@ -235,6 +235,7 @@ 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 @@ 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 diff -ur apache-1.3/src/main/buff.c apache-1.3-cygwin/src/main/buff.c --- apache-1.3/src/main/buff.c Mon Jan 15 17:04:56 2001 +++ apache-1.3-cygwin/src/main/buff.c Tue Jan 1 15:12:49 2002 @@ -121,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. @@ -283,7 +282,7 @@ { 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) @@ -1465,7 +1477,7 @@ 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) { @@ -1475,7 +1487,7 @@ 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; @@ -1500,7 +1512,7 @@ else { rc3 = 0; } -#if defined(WIN32) || defined (BEOS) || defined(NETWARE) +#if defined(WIN32) || defined (BEOS) || defined(NETWARE) || defined(CYGWIN_WINSOCK) } #endif diff -ur apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c --- apache-1.3/src/main/http_main.c Wed Oct 17 14:45:30 2001 +++ apache-1.3-cygwin/src/main/http_main.c Tue Jan 1 16:05:19 2002 @@ -1494,7 +1570,7 @@ #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 */ @@ -1554,7 +1630,7 @@ } -#if defined(WIN32) || defined(NETWARE) +#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) API_EXPORT(int) ap_check_alarm(void) { #ifdef NETWARE @@ -3987,6 +4067,9 @@ #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 -ur apache-1.3/src/os/cygwin/os.h apache-1.3-cygwin/src/os/cygwin/os.h --- apache-1.3/src/os/cygwin/os.h Thu Sep 27 18:12:04 2001 +++ apache-1.3-cygwin/src/os/cygwin/os.h Sat Nov 10 16:57:04 2001 @@ -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),