Patch: so_opentype.diff (7 in series)

Martin Wilck Martin.Wilck at fujitsu-siemens.com
Tue Apr 23 13:47:01 CDT 2002


Patch: so_opentype.diff

The SO_OPENTYPE socket option used to be represented by a static variable.
This is wrong, it is a per-thread setting (clearly stated in MSDN).
Since this option is now used to determine whether sockets created with the
socket() function should have the overlapped attribute, this must be fixed.

Fixes e.g. problem with the Hamster local news/pop3 server app, in which
several threads create overlapped sockets initially and set SO_OPENTYPE afterwards.
(In each thread, SO_OPENTYPE must initially be 0 even if another thread has set
it to 1 already).

Patch against: CVS 2002/04/23, with previous patches in series applied.

Modified files:
        include:        thread.h (add so_opentype field to thread structure)
        dlls/winsock:   socket.c

diff -ruNX ignore CVS/wine/dlls/winsock/socket.c TMP/wine/dlls/winsock/socket.c
--- CVS/wine/dlls/winsock/socket.c	Tue Apr 23 18:30:06 2002
+++ TMP/wine/dlls/winsock/socket.c	Tue Apr 23 18:30:23 2002
@@ -263,14 +263,6 @@
 	0
 };

-/* Holds value of SO_OPENTYPE socket option.  This is essentially a global
- * variable that Windows uses to affect how new sockets are created.  See
- * <http://support.microsoft.com/default.aspx?scid=kb;EN-US;q181611>.  Right
- * now, Wine does not do anything with this value other than get and set it on
- * request.
- */
-static int opentype = 0;
-
 inline static DWORD NtStatusToWSAError ( const DWORD status )
 {
     /* We only need to cover the status codes set by server async request handling */
@@ -1763,9 +1755,9 @@
             SetLastError(WSAEFAULT);
             return SOCKET_ERROR;
         }
-        *(int *)optval = opentype;
+        *(int *)optval = NtCurrentTeb()->so_opentype;
         *optlen = sizeof(int);
-        TRACE("getting global SO_OPENTYPE = 0x%x\n", opentype);
+        TRACE("getting global SO_OPENTYPE = 0x%x\n", *((int*)optval) );
         return 0;
     }

@@ -2621,8 +2613,8 @@
             SetLastError(WSAEFAULT);
             return SOCKET_ERROR;
         }
-        opentype = *(int *)optval;
-        TRACE("setting global SO_OPENTYPE to 0x%x\n", opentype);
+        NtCurrentTeb()->so_opentype = *(int *)optval;
+        TRACE("setting global SO_OPENTYPE to 0x%x\n", NtCurrentTeb()->so_opentype);
         return 0;
     }

@@ -2796,10 +2788,8 @@
 {
     TRACE("af=%d type=%d protocol=%d\n", af, type, protocol);

-    /* The Winsock2 specification states that socket() always opens sockets
-       in overlapped mode.
-       FIXME: is the SO_OPENTYPE behaviour correct? */
-    return WSASocketA ( af, type, protocol, NULL, 0, (opentype ? 0 : WSA_FLAG_OVERLAPPED) );
+    return WSASocketA ( af, type, protocol, NULL, 0,
+                        (NtCurrentTeb()->so_opentype ? 0 : WSA_FLAG_OVERLAPPED) );
 }

 /***********************************************************************
diff -ruNX ignore CVS/wine/include/thread.h TMP/wine/include/thread.h
--- CVS/wine/include/thread.h	Tue Apr  2 15:39:34 2002
+++ TMP/wine/include/thread.h	Tue Apr 23 18:30:23 2002
@@ -114,10 +114,11 @@
     DWORD        alarms;         /* --3 22c Data for vm86 mode */
     DWORD        vm86_pending;   /* --3 230 Data for vm86 mode */
     void        *vm86_ptr;       /* --3 234 Data for vm86 mode */
+    int          so_opentype;    /* --3 238 Open type for sockets SO_OPENTYPE (0 - overlapped, non-0: non-overlapped) */
     /* here is plenty space for wine specific fields (don't forget to change pad6!!) */

     /* the following are nt specific fields */
-    DWORD        pad6[624];                  /* --n 238 */
+    DWORD        pad6[620];                  /* --n 23c */
     UNICODE_STRING StaticUnicodeString;      /* -2- bf8 used by advapi32 */
     USHORT       StaticUnicodeBuffer[261];   /* -2- c00 used by advapi32 */
     DWORD        pad7;                       /* --n e0c */
Binary files CVS/wine/wine and TMP/wine/wine differ






More information about the wine-patches mailing list