apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r989790 - in /apr/apr/branches/1.4.x: apr.dsp apr.mak file_io/win32/pipe.c include/arch/win32/apr_arch_misc.h libapr.dsp libapr.mak
Date Thu, 26 Aug 2010 16:02:03 GMT
Author: mturk
Date: Thu Aug 26 16:02:03 2010
New Revision: 989790

URL: http://svn.apache.org/viewvc?rev=989790&view=rev
Log:
Backport Win32 part of poll provider for Vista+

Modified:
    apr/apr/branches/1.4.x/apr.dsp
    apr/apr/branches/1.4.x/apr.mak
    apr/apr/branches/1.4.x/file_io/win32/pipe.c
    apr/apr/branches/1.4.x/include/arch/win32/apr_arch_misc.h
    apr/apr/branches/1.4.x/libapr.dsp
    apr/apr/branches/1.4.x/libapr.mak

Modified: apr/apr/branches/1.4.x/apr.dsp
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/apr.dsp?rev=989790&r1=989789&r2=989790&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/apr.dsp (original)
+++ apr/apr/branches/1.4.x/apr.dsp Thu Aug 26 16:02:03 2010
@@ -416,6 +416,10 @@ SOURCE=.\passwd\apr_getpass.c
 # PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=.\poll\unix\poll.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\poll\unix\pollcb.c
 # End Source File
 # Begin Source File

Modified: apr/apr/branches/1.4.x/apr.mak
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/apr.mak?rev=989790&r1=989789&r2=989790&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/apr.mak (original)
+++ apr/apr/branches/1.4.x/apr.mak Thu Aug 26 16:02:03 2010
@@ -84,6 +84,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -205,6 +206,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -290,6 +292,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -412,6 +415,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -497,6 +501,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -619,6 +624,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -704,6 +710,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -826,6 +833,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -911,6 +919,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -1033,6 +1042,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -1118,6 +1128,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -1240,6 +1251,7 @@ LIB32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -1560,6 +1572,12 @@ SOURCE=.\passwd\apr_getpass.c
 	$(CPP) $(CPP_PROJ) $(SOURCE)
 
 
+SOURCE=.\poll\unix\poll.c
+
+"$(INTDIR)\poll.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
 SOURCE=.\poll\unix\pollcb.c
 
 "$(INTDIR)\pollcb.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h"
@@ -1713,7 +1731,7 @@ InputPath=.\include\apr.hw
 ".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
 	<<tempfile.bat 
 	@echo off 
-	type .\include\apr.hw > .\include\apr.h
+	type .\include\apr.hw > .\include\apr.h
 << 
 	
 
@@ -1724,7 +1742,7 @@ InputPath=.\include\apr.hw
 ".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
 	<<tempfile.bat 
 	@echo off 
-	type .\include\apr.hw > .\include\apr.h
+	type .\include\apr.hw > .\include\apr.h
 << 
 	
 
@@ -1735,7 +1753,7 @@ InputPath=.\include\apr.hw
 ".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
 	<<tempfile.bat 
 	@echo off 
-	type .\include\apr.hw > .\include\apr.h
+	type .\include\apr.hw > .\include\apr.h
 << 
 	
 
@@ -1746,7 +1764,7 @@ InputPath=.\include\apr.hw
 ".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
 	<<tempfile.bat 
 	@echo off 
-	type .\include\apr.hw > .\include\apr.h
+	type .\include\apr.hw > .\include\apr.h
 << 
 	
 
@@ -1757,7 +1775,7 @@ InputPath=.\include\apr.hw
 ".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
 	<<tempfile.bat 
 	@echo off 
-	type .\include\apr.hw > .\include\apr.h
+	type .\include\apr.hw > .\include\apr.h
 << 
 	
 
@@ -1768,7 +1786,7 @@ InputPath=.\include\apr.hw
 ".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
 	<<tempfile.bat 
 	@echo off 
-	type .\include\apr.hw > .\include\apr.h
+	type .\include\apr.hw > .\include\apr.h
 << 
 	
 

Modified: apr/apr/branches/1.4.x/file_io/win32/pipe.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/win32/pipe.c?rev=989790&r1=989789&r2=989790&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/win32/pipe.c (original)
+++ apr/apr/branches/1.4.x/file_io/win32/pipe.c Thu Aug 26 16:02:03 2010
@@ -229,8 +229,9 @@ APR_DECLARE(apr_status_t) apr_os_pipe_pu
 static apr_status_t create_socket_pipe(SOCKET *rd, SOCKET *wr)
 {
     static int id = 0;
-
+    FD_SET rs;
     SOCKET ls;
+    struct timeval socktm;
     struct sockaddr_in pa;
     struct sockaddr_in la;
     struct sockaddr_in ca;
@@ -238,7 +239,7 @@ static apr_status_t create_socket_pipe(S
     apr_status_t rv = APR_SUCCESS;
     int ll = sizeof(la);
     int lc = sizeof(ca);
-    int bm = 1;
+    unsigned long bm = 1;
     int uid[2];
     int iid[2];
 
@@ -290,17 +291,41 @@ static apr_status_t create_socket_pipe(S
         goto cleanup;
     }
     for (;;) {
+        int ns;
+        int nc = 0;
         /* Listening socket is nonblocking by now.
-         * The accept must create the socket
-         * immediatelly because we connected already.
+         * The accept should create the socket
+         * immediatelly because we are connected already.
+         * However on buys systems this can take a while
+         * until winsock gets a chance to handle the events.
          */
+        FD_ZERO(&rs);
+        FD_SET(ls, &rs);
+
+        socktm.tv_sec  = 1;
+        socktm.tv_usec = 0;
+        if ((ns = select(0, &rs, NULL, NULL, &socktm)) == SOCKET_ERROR) {
+            /* Accept still not signaled */
+            Sleep(100);
+            continue;
+        }
+        if (ns == 0) {
+            /* No connections in the last second */
+            continue;
+        }
         if ((*rd = accept(ls, (SOCKADDR *)&ca, &lc)) == INVALID_SOCKET) {
             rv =  apr_get_netos_error();
             goto cleanup;
         }
         /* Verify the connection by reading the send identification.
          */
-        nrd = recv(*rd, (char *)iid, sizeof(iid), 0);
+        do {
+            if (nc++)
+                Sleep(1);
+            nrd = recv(*rd, (char *)iid, sizeof(iid), 0);
+            rv = nrd == SOCKET_ERROR ? apr_get_netos_error() : APR_SUCCESS;
+        } while (APR_STATUS_IS_EAGAIN(rv));
+
         if (nrd == sizeof(iid)) {
             if (memcmp(uid, iid, sizeof(uid)) == 0) {
                 /* Wow, we recived what we send.
@@ -316,7 +341,6 @@ static apr_status_t create_socket_pipe(S
             }
         }
         else if (nrd == SOCKET_ERROR) {
-            rv =  apr_get_netos_error();
             goto cleanup;
         }
         closesocket(*rd);

Modified: apr/apr/branches/1.4.x/include/arch/win32/apr_arch_misc.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/include/arch/win32/apr_arch_misc.h?rev=989790&r1=989789&r2=989790&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/include/arch/win32/apr_arch_misc.h (original)
+++ apr/apr/branches/1.4.x/include/arch/win32/apr_arch_misc.h Thu Aug 26 16:02:03 2010
@@ -186,18 +186,24 @@ FARPROC apr_load_dll_func(apr_dlltoken_e
 /* The apr_load_dll_func call WILL return 0 set error to
  * ERROR_INVALID_FUNCTION if the function cannot be loaded
  */
-
 #define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
     typedef rettype (calltype *apr_winapi_fpt_##fn) args; \
     static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \
-    static APR_INLINE rettype apr_winapi_##fn args \
-    {   if (!apr_winapi_pfn_##fn) \
+    static int apr_winapi_chk_##fn = 0; \
+    static APR_INLINE int apr_winapi_ld_##fn(void) \
+    {   if (apr_winapi_pfn_##fn) return 1; \
+        if (apr_winapi_chk_##fn ++) return 0; \
+        if (!apr_winapi_pfn_##fn) \
             apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \
                                       apr_load_dll_func(lib, #fn, ord); \
-        if (apr_winapi_pfn_##fn) \
+        if (apr_winapi_pfn_##fn) return 1; else return 0; }; \
+    static APR_INLINE rettype apr_winapi_##fn args \
+    {   if (apr_winapi_ld_##fn()) \
             return (*(apr_winapi_pfn_##fn)) names; \
         else { SetLastError(ERROR_INVALID_FUNCTION); return 0;} }; \
 
+#define APR_HAVE_LATE_DLL_FUNC(fn) apr_winapi_ld_##fn()
+
 /* Provide late bound declarations of every API function missing from
  * one or more supported releases of the Win32 API
  *
@@ -432,6 +438,48 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI
     (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
+
+#ifdef SetDllDirectoryW
+#undef SetDllDirectoryW
+#endif
+APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SetDllDirectoryW, 0, (
+    IN LPCWSTR lpPathName),
+    (lpPathName));
+#define SetDllDirectoryW apr_winapi_SetDllDirectoryW
+
 #endif /* !defined(_WIN32_WCE) */
 
 #endif  /* ! MISC_H */

Modified: apr/apr/branches/1.4.x/libapr.dsp
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/libapr.dsp?rev=989790&r1=989789&r2=989790&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/libapr.dsp (original)
+++ apr/apr/branches/1.4.x/libapr.dsp Thu Aug 26 16:02:03 2010
@@ -468,6 +468,10 @@ SOURCE=.\passwd\apr_getpass.c
 # PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=.\poll\unix\poll.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\poll\unix\pollcb.c
 # End Source File
 # Begin Source File

Modified: apr/apr/branches/1.4.x/libapr.mak
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/libapr.mak?rev=989790&r1=989789&r2=989790&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/libapr.mak (original)
+++ apr/apr/branches/1.4.x/libapr.mak Thu Aug 26 16:02:03 2010
@@ -86,6 +86,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -213,6 +214,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -314,6 +316,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -442,6 +445,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -543,6 +547,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -671,6 +676,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -772,6 +778,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -900,6 +907,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -1001,6 +1009,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -1129,6 +1138,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -1230,6 +1240,7 @@ CLEAN :
 	-@erase "$(INTDIR)\open.obj"
 	-@erase "$(INTDIR)\otherchild.obj"
 	-@erase "$(INTDIR)\pipe.obj"
+	-@erase "$(INTDIR)\poll.obj"
 	-@erase "$(INTDIR)\pollcb.obj"
 	-@erase "$(INTDIR)\pollset.obj"
 	-@erase "$(INTDIR)\proc.obj"
@@ -1358,6 +1369,7 @@ LINK32_OBJS= \
 	"$(INTDIR)\socket_util.obj" \
 	"$(INTDIR)\sockopt.obj" \
 	"$(INTDIR)\apr_getpass.obj" \
+	"$(INTDIR)\poll.obj" \
 	"$(INTDIR)\pollcb.obj" \
 	"$(INTDIR)\pollset.obj" \
 	"$(INTDIR)\select.obj" \
@@ -1692,6 +1704,12 @@ SOURCE=.\passwd\apr_getpass.c
 	$(CPP) $(CPP_PROJ) $(SOURCE)
 
 
+SOURCE=.\poll\unix\poll.c
+
+"$(INTDIR)\poll.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
 SOURCE=.\poll\unix\pollcb.c
 
 "$(INTDIR)\pollcb.obj" : $(SOURCE) "$(INTDIR)" ".\include\apr.h"



Mime
View raw message