basic structures for async IO in winsock

Martin Wilck Martin.Wilck at fujitsu-siemens.com
Wed Jan 16 03:42:12 CST 2002


Patch: async-winsock.diff
Applies: CVS 2002-01-15

Introduce data structures and basic functions for asynchronous
Winsock2 operations.

ChangeLog:

include/winsock2.h:     Fix LPWSAOVERLAPPED declaration.
dlls/winsock/socket.c:  Add basic data strutures & functions for overlapped IO
                        in Winsock.

diff -ruX diffignore CVS/wine/dlls/winsock/socket.c MW/wine/dlls/winsock/socket.c
--- CVS/wine/dlls/winsock/socket.c	Tue Jan 15 20:17:38 2002
+++ MW/wine/dlls/winsock/socket.c	Wed Jan 16 10:19:13 2002
@@ -108,6 +108,72 @@
                         inet_ntoa(((struct sockaddr_in *)a)->sin_addr), \
                         ntohs(((struct sockaddr_in *)a)->sin_port))

+/****************************************************************
+ * Async IO declarations and operations
+ ****************************************************************/
+
+static DWORD ws2_async_get_status (struct async_private *ovp);
+static DWORD ws2_async_get_count  (struct async_private *ovp);
+static void  ws2_async_set_status (struct async_private *ovp, DWORD status);
+static void CALLBACK ws2_async_call_completion (ULONG_PTR data);
+
+static struct async_ops ws2_async_ops =
+{
+    ws2_async_get_status,
+    ws2_async_set_status,
+    ws2_async_get_count,
+    ws2_async_call_completion
+};
+
+typedef struct ws2_async
+{
+    async_private                       async;
+    LPWSAOVERLAPPED                     overlapped;
+    LPWSAOVERLAPPED                     user_overlapped;
+    LPWSAOVERLAPPED_COMPLETION_ROUTINE  completion_func;
+    struct iovec                        *iovec;
+    int                                 n_iovecs;
+    struct WS_sockaddr                  *addr;
+    int                                 *addrlen;
+    DWORD                               flags;
+} ws2_async;
+
+static DWORD ws2_async_get_status (struct async_private *ovp)
+{
+    return ((ws2_async*) ovp)->overlapped->Internal;
+}
+
+static VOID ws2_async_set_status (struct async_private *ovp, DWORD status)
+{
+    ((ws2_async*) ovp)->overlapped->Internal = status;
+}
+
+static DWORD ws2_async_get_count (struct async_private *ovp)
+{
+    return ((ws2_async*) ovp)->overlapped->InternalHigh;
+}
+
+static void CALLBACK ws2_async_call_completion (ULONG_PTR data)
+{
+    ws2_async* as = (ws2_async*) data;
+
+    TRACE ("data: %p\n", as);
+
+    if ( as->completion_func )
+        as->completion_func ( as->overlapped->Internal,
+                              as->overlapped->InternalHigh,
+                              as->user_overlapped,
+                              as->flags );
+
+    if ( !as->user_overlapped )
+        HeapFree ( GetProcessHeap(), 0, as->overlapped );
+
+    HeapFree ( GetProcessHeap(), 0, as->iovec );
+    HeapFree ( GetProcessHeap(), 0, as );
+}
+
+/****************************************************************/
+
 /* ----------------------------------- internal data */

 /* ws_... struct conversion flags */
diff -ruX diffignore CVS/wine/include/winsock2.h MW/wine/include/winsock2.h
--- CVS/wine/include/winsock2.h	Tue Jan 15 17:06:03 2002
+++ MW/wine/include/winsock2.h	Wed Jan 16 10:22:06 2002
@@ -204,8 +204,7 @@

 #define WSAEVENT      HANDLE
 #define LPWSAEVENT    LPHANDLE
-#define WSAOVERLAPPED OVERLAPPED
-typedef struct _OVERLAPPED* LPWSAOVERLAPPED;
+typedef OVERLAPPED    WSAOVERLAPPED, *LPWSAOVERLAPPED;

 #define WSA_IO_PENDING             (ERROR_IO_PENDING)
 #define WSA_IO_INCOMPLETE          (ERROR_IO_INCOMPLETE)








More information about the wine-patches mailing list