Commit 2d9e894d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

rpcrt4: Always protect ref access for connections associated with protseq in…

rpcrt4: Always protect ref access for connections associated with protseq in RPCRT4_ReleaseConnection. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent bb256b4f
......@@ -3382,20 +3382,24 @@ RpcConnection *RPCRT4_GrabConnection(RpcConnection *connection)
void RPCRT4_ReleaseConnection(RpcConnection *connection)
{
LONG ref = InterlockedDecrement(&connection->ref);
LONG ref;
if (!ref && connection->protseq)
/* protseq stores a list of active connections, but does not own references to them.
* It may need to grab a connection from the list, which could lead to a race if
* connection is being released, but not yet removed from the list. We handle that
* by synchronizing on CS here. */
if (connection->protseq)
{
/* protseq stores a list of active connections, but does not own references to them.
* It may need to grab a connection from the list, which could lead to a race if
* connection is being released, but not yet removed from the list. We handle that
* by synchronizing on CS here. */
EnterCriticalSection(&connection->protseq->cs);
ref = connection->ref;
ref = InterlockedDecrement(&connection->ref);
if (!ref)
list_remove(&connection->protseq_entry);
LeaveCriticalSection(&connection->protseq->cs);
}
else
{
ref = InterlockedDecrement(&connection->ref);
}
TRACE("%p ref=%u\n", connection, ref);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment