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;
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;
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;
*/
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);
}
/***********************************************************************
*/
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)
/* 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);
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);