Obtained from:
Submitted by: Stipe Tolj <tolj@wapme-systems.de>
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
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 <tolj@wapme-systems.de>]
+
*) Use "httpready" accept filter rather than "dataready" on
FreeBSD after 4.1.1-RELEASE where it works correctly.
[Tony Finch]
# 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
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.
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`
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
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
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"
#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
* 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.
{
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)
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) {
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;
else {
rc3 = 0;
}
-#if defined(WIN32) || defined (BEOS) || defined(NETWARE)
+#if defined(WIN32) || defined (BEOS) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
}
#endif
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 <tolj@wapme-systems.de>
+ */
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);
#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 */
}
-#if defined(WIN32) || defined(NETWARE)
+#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK)
API_EXPORT(int) ap_check_alarm(void)
{
#ifdef NETWARE
#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
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
$(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;
#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),