apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r744552 - in /apr/apr/trunk: CHANGES apr.dsp include/arch/unix/apr_arch_poll_private.h include/arch/win32/apr_arch_misc.h libapr.dsp poll/unix/poll.c poll/unix/select.c
Date Sat, 14 Feb 2009 18:55:10 GMT
Author: mturk
Date: Sat Feb 14 18:55:10 2009
New Revision: 744552

URL: http://svn.apache.org/viewvc?rev=744552&view=rev
Log:
Use WSApoll if supported by winsock

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/apr.dsp
    apr/apr/trunk/include/arch/unix/apr_arch_poll_private.h
    apr/apr/trunk/include/arch/win32/apr_arch_misc.h
    apr/apr/trunk/libapr.dsp
    apr/apr/trunk/poll/unix/poll.c
    apr/apr/trunk/poll/unix/select.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sat Feb 14 18:55:10 2009
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 2.0.0
 
+  *) Win32: Use WSAPoll as default pollset method if supported and
+     found inside winsock dll.
+     [Mladen Turk]
+
   *) Make apr_pollset and apr_pollcb implementations using providers.
      Added apr_pollset_create_ex and apr_pollcb_create_ex that allows
      choosing non-default providers.

Modified: apr/apr/trunk/apr.dsp
URL: http://svn.apache.org/viewvc/apr/apr/trunk/apr.dsp?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/apr.dsp (original)
+++ apr/apr/trunk/apr.dsp Sat Feb 14 18:55:10 2009
@@ -420,6 +420,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\poll\unix\poll.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\poll\unix\select.c
 # End Source File
 # End Group

Modified: apr/apr/trunk/include/arch/unix/apr_arch_poll_private.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/unix/apr_arch_poll_private.h?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/unix/apr_arch_poll_private.h (original)
+++ apr/apr/trunk/include/arch/unix/apr_arch_poll_private.h Sat Feb 14 18:55:10 2009
@@ -63,11 +63,15 @@
 #define POLLSET_DEFAULT_METHOD APR_POLLSET_SELECT
 #endif
 
+#ifdef WIN32
+#define POLL_USES_SELECT
+#else
 #ifdef HAVE_POLL
 #define POLL_USES_POLL
 #else
 #define POLL_USES_SELECT
 #endif
+#endif
 
 #if defined(POLLSET_USES_KQUEUE) || defined(POLLSET_USES_EPOLL) || defined(POLLSET_USES_PORT)
 

Modified: apr/apr/trunk/include/arch/win32/apr_arch_misc.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/win32/apr_arch_misc.h?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/win32/apr_arch_misc.h (original)
+++ apr/apr/trunk/include/arch/win32/apr_arch_misc.h Sat Feb 14 18:55:10 2009
@@ -436,6 +436,40 @@
     (hSnapshot, lppe));
 #define Process32NextW apr_winapi_Process32NextW
 
+#if !defined(POLLERR)
+/* Event flag definitions for WSAPoll(). */
+#define POLLRDNORM  0x0100
+#define POLLRDBAND  0x0200
+#define POLLIN      (POLLRDNORM | POLLRDBAND)
+#define POLLPRI     0x0400
+
+#define POLLWRNORM  0x0010
+#define POLLOUT     (POLLWRNORM)
+#define POLLWRBAND  0x0020
+
+#define POLLERR     0x0001
+#define POLLHUP     0x0002
+#define POLLNVAL    0x0004
+
+typedef struct pollfd {
+    SOCKET  fd;
+    SHORT   events;
+    SHORT   revents;
+
+} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD;
+
+#endif /* !defined(POLLERR) */
+#ifdef WSAPoll
+#undef WSAPoll
+#endif
+APR_DECLARE_LATE_DLL_FUNC(DLL_WINSOCK2API, int, WSAAPI, WSAPoll, 0, (
+    IN OUT LPWSAPOLLFD fdArray,
+    IN ULONG fds,
+    IN INT timeout),
+    (fdArray, fds, timeout));
+#define WSAPoll apr_winapi_WSAPoll
+#define HAVE_POLL   1
+
 #endif /* !defined(_WIN32_WCE) */
 
 #endif  /* ! MISC_H */

Modified: apr/apr/trunk/libapr.dsp
URL: http://svn.apache.org/viewvc/apr/apr/trunk/libapr.dsp?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/libapr.dsp (original)
+++ apr/apr/trunk/libapr.dsp Sat Feb 14 18:55:10 2009
@@ -472,6 +472,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\poll\unix\poll.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\poll\unix\select.c
 # End Source File
 # End Group

Modified: apr/apr/trunk/poll/unix/poll.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/poll.c?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/poll.c (original)
+++ apr/apr/trunk/poll/unix/poll.c Sat Feb 14 18:55:10 2009
@@ -167,6 +167,11 @@
     if (flags & APR_POLLSET_THREADSAFE) {                
         return APR_ENOTIMPL;
     }
+#ifdef WIN32
+    if (!APR_HAVE_LATE_DLL_FUNC(WSAPoll)) {
+        return APR_ENOTIMPL;
+    }
+#endif
     pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
     pollset->p->pollset = apr_palloc(p, size * sizeof(struct pollfd));
     pollset->p->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
@@ -188,9 +193,16 @@
         pollset->p->pollset[pollset->nelts].fd = descriptor->desc.s->socketdes;
     }
     else {
+#if APR_FILES_AS_SOCKETS
         pollset->p->pollset[pollset->nelts].fd = descriptor->desc.f->filedes;
+#else
+        if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
+            descriptor->desc.f == pollset->wakeup_pipe[0])
+            pollset->p->pollset[pollset->nelts].fd = (SOCKET)descriptor->desc.f->filedes;
+        else
+            return APR_EBADF;
+#endif
     }
-
     pollset->p->pollset[pollset->nelts].events =
         get_event(descriptor->reqevents);
     pollset->nelts++;
@@ -238,7 +250,11 @@
     if (timeout > 0) {
         timeout /= 1000;
     }
+#ifdef WIN32
+    ret = WSAPoll(pollset->p->pollset, pollset->nelts, (int)timeout);
+#else
     ret = poll(pollset->p->pollset, pollset->nelts, timeout);
+#endif
     (*num) = ret;
     if (ret < 0) {
         return apr_get_netos_error();
@@ -311,7 +327,11 @@
         pollcb->pollset.ps[pollcb->nelts].fd = descriptor->desc.s->socketdes;
     }
     else {
+#if APR_FILES_AS_SOCKETS
         pollcb->pollset.ps[pollcb->nelts].fd = descriptor->desc.f->filedes;
+#else
+        return APR_EBADF;
+#endif
     }
 
     pollcb->pollset.ps[pollcb->nelts].events =
@@ -357,12 +377,16 @@
 {
     int ret;
     apr_status_t rv = APR_SUCCESS;
-    apr_uint32_t i, j;
+    apr_uint32_t i;
 
     if (timeout > 0) {
         timeout /= 1000;
     }
+#ifdef WIN32
+    ret = WSAPoll(pollcb->pollset.ps, pollcb->nelts, (int)timeout);
+#else
     ret = poll(pollcb->pollset.ps, pollcb->nelts, timeout);
+#endif
     if (ret < 0) {
         return apr_get_netos_error();
     }

Modified: apr/apr/trunk/poll/unix/select.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/select.c?rev=744552&r1=744551&r2=744552&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/select.c (original)
+++ apr/apr/trunk/poll/unix/select.c Sat Feb 14 18:55:10 2009
@@ -233,7 +233,11 @@
     }
     else {
 #if !APR_FILES_AS_SOCKETS
-        return APR_EBADF;
+        if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
+            descriptor->desc.f == pollset->wakeup_pipe[0])
+            fd = (apr_os_sock_t)descriptor->desc.f->filedes;
+        else
+            return APR_EBADF;
 #else
 #ifdef NETWARE
         /* NetWare can't handle mixed descriptor types in select() */



Mime
View raw message