> Win32 doesn't use read/write, it uses send/recv. While the read/write
> oftentimes works, it's less than effective on occasion.
>
> I suspect either the cygwin thunk is misbehaving, or we have compensated
> in the server but the cygwin port doesn't pick up those exceptions. Grep
> throughout the source for send/recv where we've #ifdef'ed Win32, consider
> including CYGWIN in those exceptions and see what you observe.
thanks a lot for the hint.
Attached is a patch that shows what I have changed in current CVS to
make apache-1.3 run with Win32 API specific send/recv functions.
I have this apache-1.3.23-dev version running on apache.dev.wapme.net
and will see how it behaves for the upcoming days. If it is considered
better, I would suggest to include the patch to official CVS tree.
Here are the ChangeLog entries:
* src/Configuration.tmpl: added rule CYGWIN_WINSOCK which may be
used at configure time to indicate that we want Win32 API style
functions instead of POSIX.
* src/Configure: added necessary line for helpers/CutRule to fetch
CYGWIN_WINSOCK rule and an additional if statement to Cygwin's compile
flag block to include a seperate define CYGWIN_WINSOCK and the
required import library libwsock32.a.
* src/main/buff.c: added additional #ifdef ORs for CYGWIN_WINSOCK to
include Win32 API code.
* src/main/http_main.c: added additional #ifdef ORs for
CYGWIN_WINSOCK to include Win32 API code.
* src/os/cygwin/os.h: added necessary #define's and function
prototype declaration for Win32 API functions.
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 29 00:39:02 2001
+++ apache-1.3-cygwin/src/Configuration.tmpl Sun Oct 28 16:42:58 2001
@@ -173,6 +173,11 @@
# 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 style.
+#
Rule SOCKS4=no
Rule SOCKS5=no
@@ -180,6 +185,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 29 00:39:08 2001
+++ apache-1.3-cygwin/src/Configure Sun Oct 28 16:54:58 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
+ OS="$OS w/Win32 API"
+ 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 Oct 29 00:39:14 2001
+++ apache-1.3-cygwin/src/main/buff.c Sun Oct 28 16:55:38 2001
@@ -121,7 +121,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 +283,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)
@@ -356,7 +356,7 @@
{
int rv;
-#if defined(WIN32) || defined(NETWARE)
+#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
if (fb->flags & B_SOCKET) {
rv = sendwithtimeout(fb->fd, buf, nbyte, 0);
if (rv == SOCKET_ERROR)
@@ -1465,7 +1465,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 +1475,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 +1500,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 Mon Oct 29 00:39:36 2001
+++ apache-1.3-cygwin/src/main/http_main.c Sun Oct 28 17:03:12 2001
@@ -1494,7 +1494,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 +1554,7 @@
}
-#if defined(WIN32) || defined(NETWARE)
+#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
API_EXPORT(int) ap_check_alarm(void)
{
#ifdef NETWARE
@@ -3986,6 +3986,9 @@
#endif
#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: */
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 Mon Oct 29 00:39:36 2001
+++ apache-1.3-cygwin/src/os/cygwin/os.h Sun Oct 28 17:18:10 2001
@@ -89,6 +89,24 @@
#endif
/*
+ * Define winsock.h and winsock2.h stuff taken from Win32 API in case we
+ * want to do socket communication in Win32 style rather then POSIX.
+ * These are needed for main/buff.c and main/http_main.c. They are linked
+ * against libwsock32.a for the import declarations.
+ */
+#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),
* and prototypes of OS specific functions defined in os.c or os-inline.c