Module: wine Branch: master Commit: 375c68a0435af54e97889d5bfbbe7ecdfbe2010b URL: http://source.winehq.org/git/wine.git/?a=commit;h=375c68a0435af54e97889d5bfb...
Author: Rob Shearman robertshearman@gmail.com Date: Thu Mar 26 13:35:36 2009 +0000
rpcrt4: Re-use already registered endpoints for a protocol sequence.
Return RPC_S_INVALID_ENDPOINT_FORMAT if a NULL endpoint is passed into RpcServerUseProtseqEp{,Ex}{A,W}.
---
dlls/rpcrt4/rpc_server.c | 49 ++++++++++++++++++++++++++++++++++++-- dlls/rpcrt4/tests/rpc_protseq.c | 2 - 2 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c index 12a525d..4a87bd0 100644 --- a/dlls/rpcrt4/rpc_server.c +++ b/dlls/rpcrt4/rpc_server.c @@ -566,11 +566,32 @@ static void RPCRT4_stop_listen(BOOL auto_listen) LeaveCriticalSection(&listen_cs); }
+static BOOL RPCRT4_protseq_is_endpoint_registered(RpcServerProtseq *protseq, LPCSTR endpoint) +{ + RpcConnection *conn; + EnterCriticalSection(&protseq->cs); + for (conn = protseq->conn; conn; conn = conn->Next) + { + if (!endpoint || !strcmp(endpoint, conn->Endpoint)) + break; + } + LeaveCriticalSection(&protseq->cs); + return (conn != NULL); +} + static RPC_STATUS RPCRT4_use_protseq(RpcServerProtseq* ps, LPSTR endpoint) { RPC_STATUS status;
- status = ps->ops->open_endpoint(ps, endpoint); + EnterCriticalSection(&ps->cs); + + if (RPCRT4_protseq_is_endpoint_registered(ps, endpoint)) + status = RPC_S_OK; + else + status = ps->ops->open_endpoint(ps, endpoint); + + LeaveCriticalSection(&ps->cs); + if (status != RPC_S_OK) return status;
@@ -751,6 +772,9 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExA( RPC_CSTR Protseq, UINT MaxCalls, RPC debugstr_a(szep), SecurityDescriptor, lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
+ if (!Endpoint) + return RPC_S_INVALID_ENDPOINT_FORMAT; + status = RPCRT4_get_or_create_serverprotseq(MaxCalls, RPCRT4_strdupA(szps), &ps); if (status != RPC_S_OK) return status; @@ -772,6 +796,9 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExW( RPC_WSTR Protseq, UINT MaxCalls, RPC debugstr_w( Endpoint ), SecurityDescriptor, lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
+ if (!Endpoint) + return RPC_S_INVALID_ENDPOINT_FORMAT; + status = RPCRT4_get_or_create_serverprotseq(MaxCalls, RPCRT4_strdupWtoA(Protseq), &ps); if (status != RPC_S_OK) return status; @@ -787,8 +814,16 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExW( RPC_WSTR Protseq, UINT MaxCalls, RPC */ RPC_STATUS WINAPI RpcServerUseProtseqA(RPC_CSTR Protseq, unsigned int MaxCalls, void *SecurityDescriptor) { + RPC_STATUS status; + RpcServerProtseq* ps; + TRACE("(Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)\n", debugstr_a((char*)Protseq), MaxCalls, SecurityDescriptor); - return RpcServerUseProtseqEpA(Protseq, MaxCalls, NULL, SecurityDescriptor); + + status = RPCRT4_get_or_create_serverprotseq(MaxCalls, RPCRT4_strdupA((const char *)Protseq), &ps); + if (status != RPC_S_OK) + return status; + + return RPCRT4_use_protseq(ps, NULL); }
/*********************************************************************** @@ -796,8 +831,16 @@ RPC_STATUS WINAPI RpcServerUseProtseqA(RPC_CSTR Protseq, unsigned int MaxCalls, */ RPC_STATUS WINAPI RpcServerUseProtseqW(RPC_WSTR Protseq, unsigned int MaxCalls, void *SecurityDescriptor) { + RPC_STATUS status; + RpcServerProtseq* ps; + TRACE("Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)\n", debugstr_w(Protseq), MaxCalls, SecurityDescriptor); - return RpcServerUseProtseqEpW(Protseq, MaxCalls, NULL, SecurityDescriptor); + + status = RPCRT4_get_or_create_serverprotseq(MaxCalls, RPCRT4_strdupWtoA(Protseq), &ps); + if (status != RPC_S_OK) + return status; + + return RPCRT4_use_protseq(ps, NULL); }
void RPCRT4_destroy_all_protseqs(void) diff --git a/dlls/rpcrt4/tests/rpc_protseq.c b/dlls/rpcrt4/tests/rpc_protseq.c index a4589d6..a9b98a0 100644 --- a/dlls/rpcrt4/tests/rpc_protseq.c +++ b/dlls/rpcrt4/tests/rpc_protseq.c @@ -46,7 +46,6 @@ static void test_RpcServerUseProtseq(void) /* show that RpcServerUseProtseqEp(..., NULL, ...) isn't the same as * RpcServerUseProtseq(...) */ status = RpcServerUseProtseqEp(ncalrpc, 0, NULL, NULL); - todo_wine ok(status == RPC_S_INVALID_ENDPOINT_FORMAT, "RpcServerUseProtseqEp with NULL endpoint should have failed with " "RPC_S_INVALID_ENDPOINT_FORMAT instead of %d\n", status); @@ -111,7 +110,6 @@ static void test_RpcServerUseProtseq(void) status = RpcServerInqBindings(&bindings); ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); binding_count_after2 = bindings->Count; - todo_wine ok(binding_count_after2 == binding_count_after1, "bindings should have been re-used - after1: %u after2: %u\n", binding_count_after1, binding_count_after2);