summaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorRoy T. Fielding <fielding@apache.org>1999-08-26 19:58:01 +0200
committerRoy T. Fielding <fielding@apache.org>1999-08-26 19:58:01 +0200
commit5030a21695ccbbe139cff19a2e3b6b92829811b7 (patch)
treebd28c22deee2be645d06c286765f874cfae30e03 /os
parentChanges for thread safety in pthreads. (diff)
downloadapache2-5030a21695ccbbe139cff19a2e3b6b92829811b7.tar.xz
apache2-5030a21695ccbbe139cff19a2e3b6b92829811b7.zip
OS/2 EMX library's select() isn't thread safe so bypass it and go direct to
the OS/2 API call. Unfortunately this only works on socket handles which will break probe_writable_fds() so I'll have to find a way to fix that too. Submitted by: Brian Havard git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83796 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'os')
-rw-r--r--os/os2/util_os2.c93
1 files changed, 92 insertions, 1 deletions
diff --git a/os/os2/util_os2.c b/os/os2/util_os2.c
index 820ea61800..86128412cf 100644
--- a/os/os2/util_os2.c
+++ b/os/os2/util_os2.c
@@ -68,7 +68,7 @@ int ap_os_kill(pid_t pid, int sig)
char *ap_os_error_message(int err)
{
static char result[200];
- char message[HUGE_STRING_LEN];
+ unsigned char message[HUGE_STRING_LEN];
ULONG len;
char *pos;
int c;
@@ -94,3 +94,94 @@ char *ap_os_error_message(int err)
return result;
}
+
+
+
+
+int (*os2_select)( int *, int, int, int, long ) = NULL;
+static HMODULE hSO32DLL;
+
+int ap_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
+{
+ int *fds, s, fd_count=0, rc;
+ int num_read, num_write, num_except;
+ long ms_timeout = -1;
+
+ if (os2_select == NULL) {
+ DosEnterCritSec(); /* Stop two threads doing this at the same time */
+
+ if (os2_select == NULL) {
+ hSO32DLL = ap_os_dso_load("SO32DLL");
+
+ if (hSO32DLL) {
+ os2_select = ap_os_dso_sym(hSO32DLL, "SELECT");
+ }
+ }
+ DosExitCritSec();
+ }
+
+ ap_assert(os2_select != NULL);
+ fds = alloca(sizeof(int) * nfds);
+
+ if (readfds) {
+ for (s=0; s<nfds; s++)
+ if (FD_ISSET(s, readfds))
+ fds[fd_count++] = _getsockhandle(s);
+ }
+
+ num_read = fd_count;
+
+ if (writefds) {
+ for (s=0; s<nfds; s++)
+ if (FD_ISSET(s, writefds))
+ fds[fd_count++] = _getsockhandle(s);
+ }
+
+ num_write = fd_count - num_read;
+
+ if (exceptfds) {
+ for (s=0; s<nfds; s++)
+ if (FD_ISSET(s, exceptfds))
+ fds[fd_count++] = _getsockhandle(s);
+ }
+
+ num_except = fd_count - num_read - num_write;
+
+ if (timeout)
+ ms_timeout = timeout->tv_usec / 1000 + timeout->tv_sec * 1000;
+
+ rc = os2_select(fds, num_read, num_write, num_except, ms_timeout);
+
+ if (rc > 0) {
+ fd_count = 0;
+
+ if (readfds) {
+ for (s=0; s<nfds; s++) {
+ if (FD_ISSET(s, readfds)) {
+ if (fds[fd_count++] < 0)
+ FD_CLR(s, readfds);
+ }
+ }
+ }
+
+ if (writefds) {
+ for (s=0; s<nfds; s++) {
+ if (FD_ISSET(s, writefds)) {
+ if (fds[fd_count++] < 0)
+ FD_CLR(s, writefds);
+ }
+ }
+ }
+
+ if (exceptfds) {
+ for (s=0; s<nfds; s++) {
+ if (FD_ISSET(s, exceptfds)) {
+ if (fds[fd_count++] < 0)
+ FD_CLR(s, exceptfds);
+ }
+ }
+ }
+ }
+
+ return rc;
+}