Robert Shearman : rpcrt4: Move the packet manipulation from the exception filter to the exception handler .

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 19 16:18:14 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 0da8836ff7e9d838689f319f07670083f19a87ed
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=0da8836ff7e9d838689f319f07670083f19a87ed

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon Jun 19 20:26:57 2006 +0100

rpcrt4: Move the packet manipulation from the exception filter to the exception handler.

Remove the unused server_sem variable.

---

 dlls/rpcrt4/rpc_server.c |   38 ++++++++------------------------------
 1 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index 5beff9a..dd55848 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -47,8 +47,6 @@ #include "rpc_misc.h"
 #include "rpc_message.h"
 #include "rpc_defs.h"
 
-#define MAX_THREADS 128
-
 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
 
 typedef struct _RpcPacket
@@ -102,10 +100,6 @@ static HANDLE mgr_mutex;
 /* set when server thread has finished opening connections */
 static HANDLE server_ready_event;
 
-static HANDLE server_sem;
-
-static LONG worker_tls;
-
 static UUID uuid_nil;
 
 inline static RpcObjTypeMap *LookupObjTypeMap(UUID *ObjUuid)
@@ -153,24 +147,11 @@ static RpcServerInterface* RPCRT4_find_i
   return cif;
 }
 
-typedef struct {
-  PRPC_MESSAGE msg;
-  void* buf;
-} packet_state;
-
 static WINE_EXCEPTION_FILTER(rpc_filter)
 {
-  packet_state* state;
-  PRPC_MESSAGE msg;
-  state = TlsGetValue(worker_tls);
-  msg = state->msg;
-  if (msg->Buffer != state->buf) I_RpcFreeBuffer(msg);
-  msg->RpcFlags |= WINE_RPCFLAG_EXCEPTION;
-  msg->BufferLength = sizeof(DWORD);
-  I_RpcGetBuffer(msg);
-  *(DWORD*)msg->Buffer = GetExceptionCode();
-  WARN("exception caught with code 0x%08lx = %ld\n", *(DWORD*)msg->Buffer, *(DWORD*)msg->Buffer);
+  WARN("exception caught with code 0x%08lx = %ld\n", GetExceptionCode(), GetExceptionCode());
   TRACE("returning failure packet\n");
+  /* catch every exception */
   return EXCEPTION_EXECUTE_HANDLER;
 }
 
@@ -178,16 +159,11 @@ static void RPCRT4_process_packet(RpcCon
 {
   RpcServerInterface* sif;
   RPC_DISPATCH_FUNCTION func;
-  packet_state state;
   UUID *object_uuid;
   RpcPktHdr *response;
   void *buf = msg->Buffer;
   RPC_STATUS status;
 
-  state.msg = msg;
-  state.buf = buf;
-  TlsSetValue(worker_tls, &state);
-
   switch (hdr->common.ptype) {
     case PKT_BIND:
       TRACE("got bind packet\n");
@@ -279,7 +255,12 @@ static void RPCRT4_process_packet(RpcCon
       __TRY {
         if (func) func(msg);
       } __EXCEPT(rpc_filter) {
-        /* failure packet was created in rpc_filter */
+        if (msg->Buffer != buf) I_RpcFreeBuffer(msg);
+        /* this will cause a failure packet to be sent in I_RpcSend */
+        msg->RpcFlags |= WINE_RPCFLAG_EXCEPTION;
+        msg->BufferLength = sizeof(DWORD);
+        I_RpcGetBuffer(msg);
+        *(DWORD*)msg->Buffer = GetExceptionCode();
       } __ENDTRY
 
       /* send response packet */
@@ -304,7 +285,6 @@ fail:
   I_RpcFreeBuffer(msg);
   msg->Buffer = NULL;
   RPCRT4_FreeHeader(hdr);
-  TlsSetValue(worker_tls, NULL);
   HeapFree(GetProcessHeap(), 0, msg);
 }
 
@@ -512,8 +492,6 @@ static RPC_STATUS RPCRT4_start_listen(BO
       if (!mgr_mutex) mgr_mutex = CreateMutexW(NULL, FALSE, NULL);
       if (!mgr_event) mgr_event = CreateEventW(NULL, FALSE, FALSE, NULL);
       if (!server_ready_event) server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
-      if (!server_sem) server_sem = CreateSemaphoreW(NULL, 0, MAX_THREADS, NULL);
-      if (!worker_tls) worker_tls = TlsAlloc();
       std_listen = TRUE;
       server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, NULL, 0, NULL);
       CloseHandle(server_thread);




More information about the wine-cvs mailing list