rpcrt4: Reset assoc_group_id on associations with no active connection.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-10-16 14:38:35 +02:00 committed by Alexandre Julliard
parent c4d85843c0
commit 3b4f3ff397
3 changed files with 14 additions and 0 deletions

View File

@ -80,6 +80,7 @@ static RPC_STATUS RpcAssoc_Alloc(LPCSTR Protseq, LPCSTR NetworkAddr,
assoc->Endpoint = RPCRT4_strdupA(Endpoint);
assoc->NetworkOptions = NetworkOptions ? RPCRT4_strdupW(NetworkOptions) : NULL;
assoc->assoc_group_id = 0;
assoc->connection_cnt = 0;
UuidCreate(&assoc->http_uuid);
list_init(&assoc->entry);
*assoc_out = assoc;
@ -422,6 +423,7 @@ RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
return status;
}
InterlockedIncrement(&assoc->connection_cnt);
*Connection = NewConnection;
return RPC_S_OK;
@ -437,6 +439,15 @@ void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection)
LeaveCriticalSection(&assoc->cs);
}
void RpcAssoc_ConnectionReleased(RpcAssoc *assoc)
{
if (InterlockedDecrement(&assoc->connection_cnt))
return;
TRACE("Last %p connection released\n", assoc);
assoc->assoc_group_id = 0;
}
RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard,
NDR_SCONTEXT *SContext)
{

View File

@ -41,6 +41,7 @@ typedef struct _RpcAssoc
/* client-only */
/* connections available to be used (protected by cs) */
struct list free_connection_pool;
LONG connection_cnt;
/* server-only */
struct list context_handle_list; /* protected by cs */
@ -59,3 +60,4 @@ RPC_STATUS RpcServerAssoc_UpdateContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SCon
unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock) DECLSPEC_HIDDEN;
void RpcContextHandle_GetUuid(NDR_SCONTEXT SContext, UUID *uuid) DECLSPEC_HIDDEN;
BOOL RpcContextHandle_IsGuardCorrect(NDR_SCONTEXT SContext, void *CtxGuard) DECLSPEC_HIDDEN;
void RpcAssoc_ConnectionReleased(RpcAssoc *assoc) DECLSPEC_HIDDEN;

View File

@ -3419,6 +3419,7 @@ void RPCRT4_ReleaseConnection(RpcConnection *connection)
/* server-only */
if (connection->server_binding) RPCRT4_ReleaseBinding(connection->server_binding);
else if (connection->assoc) RpcAssoc_ConnectionReleased(connection->assoc);
if (connection->wait_release) SetEvent(connection->wait_release);