Sync to Wine-0_9_5:
Robert Shearman <rob@codeweavers.com>
- rpcrt4: Fix race condition in RpcServerListen.
  The DontWait parameter is used for forcing the function not to wait
  for the server to finish.
- rpcrt4: Implement callback conformance.
Modified: trunk/reactos/lib/rpcrt4/ndr_marshall.c
Modified: trunk/reactos/lib/rpcrt4/rpc_server.c

Modified: trunk/reactos/lib/rpcrt4/ndr_marshall.c
--- trunk/reactos/lib/rpcrt4/ndr_marshall.c	2006-01-06 20:21:22 UTC (rev 20623)
+++ trunk/reactos/lib/rpcrt4/ndr_marshall.c	2006-01-06 20:24:26 UTC (rev 20624)
@@ -375,9 +375,17 @@
     ptr = *(LPVOID*)ptr;
     break;
   case RPC_FC_CALLBACK:
+  {
+    unsigned char *old_stack_top = pStubMsg->StackTop;
+    pStubMsg->StackTop = ptr;
+
     /* ofs is index into StubDesc->apfnExprEval */
-    FIXME("handle callback\n");
+    TRACE("callback conformance into apfnExprEval[%d]\n", ofs);
+    pStubMsg->StubDesc->apfnExprEval[ofs](pStubMsg);
+
+    pStubMsg->StackTop = old_stack_top;
     goto finish_conf;
+  }
   default:
     break;
   }

Modified: trunk/reactos/lib/rpcrt4/rpc_server.c
--- trunk/reactos/lib/rpcrt4/rpc_server.c	2006-01-06 20:21:22 UTC (rev 20623)
+++ trunk/reactos/lib/rpcrt4/rpc_server.c	2006-01-06 20:24:26 UTC (rev 20624)
@@ -989,6 +989,9 @@
 
   status = RPCRT4_start_listen(FALSE);
 
+  if (status == RPC_S_OK)
+    RPCRT4_sync_with_server_thread();
+
   if (DontWait || (status != RPC_S_OK)) return status;
 
   return RpcMgmtWaitServerListen();
@@ -1010,8 +1013,6 @@
   
   LeaveCriticalSection(&listen_cs);
 
-  RPCRT4_sync_with_server_thread();
-
   return RPC_S_OK;
 }