rpc server patch

Ove Kaaven ovek at arcticnet.no
Thu Apr 17 21:36:25 CDT 2003


This turned out to be that annoying bug that haunted my DCOM work for so
long...

Anyway, now that we've finally gotten it to work, I plan to submit my
DCOM work to Wine piecewise over the next days or weeks, but how long
it'll take will probably depend on how much effort I should spend on
cleaning up some of the improperly implemented things and try to
reimplement them properly, or just submit all the hacks I used as they
are without fixing them up, and also how much attention I should give to
conflicts with Marcus's stuff. I wonder what you guys feel about that?

Log:
Ove Kaaven <ovek at transgaming.com>
Fixed a race condition on RPC worker thread creation, and a typo.

Index: dlls/rpcrt4/rpc_server.c
===================================================================
RCS file: /cvsroot/rewind/rewind/dlls/rpcrt4/rpc_server.c,v
retrieving revision 1.12
diff -u -r1.12 rpc_server.c
--- dlls/rpcrt4/rpc_server.c	18 Apr 2003 02:04:17 -0000	1.12
+++ dlls/rpcrt4/rpc_server.c	18 Apr 2003 02:16:51 -0000
@@ -285,11 +286,18 @@
 
 static void RPCRT4_new_client(RpcConnection* conn)
 {
-  conn->thread = CreateThread(NULL, 0, RPCRT4_io_thread, conn, 0, NULL);
-  if (!conn->thread) {
+  HANDLE thread = CreateThread(NULL, 0, RPCRT4_io_thread, conn, 0, NULL);
+  if (!thread) {
     DWORD err = GetLastError();
     ERR("failed to create thread, error=%08lx\n", err);
+    RPCRT4_DestroyConnection(conn);
   }
+  /* we could set conn->thread, but then we'd have to make the io_thread wait
+   * for that, otherwise the thread might finish, destroy the connection, and
+   * free the memory we'd write to before we did, causing crashes and stuff -
+   * so let's implement that later, when we really need conn->thread */
+
+  CloseHandle( thread );
 }
 
 static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
@@ -315,7 +323,7 @@
       }
       cps = cps->Next;
     }
-    /* make array of connings */
+    /* make array of connections */
     objs = HeapReAlloc(GetProcessHeap(), 0, objs, count*sizeof(HANDLE));
     objs[0] = m_event;
     count = 1;






More information about the wine-patches mailing list