rpcrt4: Add a reference to the binding object in I_RpcNegotiateTransferSyntax and release the reference in I_RpcFreeBuffer.
This is needed because a context binding handle could be released on unmarshall, but it still needs to stay valid until the binding handle is no longer being used. Re-use the previously unused RPCRT4_ExportBinding function as RPCRT4_AddRefBinding and rename RPCRT4_DestroyBinding to RPCRT4_ReleaseBinding to show that it's purpose is to release a reference count and destroy if necessary, not always destroy.
This commit is contained in:
parent
c7f9b9347f
commit
8aeb2858e4
|
@ -249,14 +249,12 @@ RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection)
|
|||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding)
|
||||
void RPCRT4_AddRefBinding(RpcBinding* Binding)
|
||||
{
|
||||
InterlockedIncrement(&OldBinding->refs);
|
||||
*Binding = OldBinding;
|
||||
return RPC_S_OK;
|
||||
InterlockedIncrement(&Binding->refs);
|
||||
}
|
||||
|
||||
RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding)
|
||||
RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding)
|
||||
{
|
||||
if (InterlockedDecrement(&Binding->refs))
|
||||
return RPC_S_OK;
|
||||
|
@ -661,7 +659,7 @@ RPC_STATUS WINAPI RpcBindingFree( RPC_BINDING_HANDLE* Binding )
|
|||
{
|
||||
RPC_STATUS status;
|
||||
TRACE("(%p) = %p\n", Binding, *Binding);
|
||||
status = RPCRT4_DestroyBinding(*Binding);
|
||||
status = RPCRT4_ReleaseBinding(*Binding);
|
||||
if (status == RPC_S_OK) *Binding = 0;
|
||||
return status;
|
||||
}
|
||||
|
@ -741,7 +739,7 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingA( RPC_CSTR StringBinding, RPC_BIND
|
|||
if (ret == RPC_S_OK)
|
||||
*Binding = (RPC_BINDING_HANDLE)bind;
|
||||
else
|
||||
RPCRT4_DestroyBinding(bind);
|
||||
RPCRT4_ReleaseBinding(bind);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -780,7 +778,7 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingW( RPC_WSTR StringBinding, RPC_BIND
|
|||
if (ret == RPC_S_OK)
|
||||
*Binding = (RPC_BINDING_HANDLE)bind;
|
||||
else
|
||||
RPCRT4_DestroyBinding(bind);
|
||||
RPCRT4_ReleaseBinding(bind);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -145,8 +145,8 @@ RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* Old
|
|||
RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint);
|
||||
RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid);
|
||||
RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
|
||||
RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding);
|
||||
RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding);
|
||||
void RPCRT4_AddRefBinding(RpcBinding* Binding);
|
||||
RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding);
|
||||
RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
|
||||
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId);
|
||||
RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
|
||||
|
|
|
@ -1017,7 +1017,10 @@ RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax(PRPC_MESSAGE pMsg)
|
|||
&cif->InterfaceId);
|
||||
|
||||
if (status == RPC_S_OK)
|
||||
{
|
||||
pMsg->ReservedForRuntime = conn;
|
||||
RPCRT4_AddRefBinding(bind);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1114,6 +1117,7 @@ RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
|
|||
{
|
||||
RpcConnection *conn = pMsg->ReservedForRuntime;
|
||||
RPCRT4_CloseBinding(bind, conn);
|
||||
RPCRT4_ReleaseBinding(bind);
|
||||
pMsg->ReservedForRuntime = NULL;
|
||||
}
|
||||
I_RpcFree(pMsg->Buffer);
|
||||
|
|
|
@ -1551,7 +1551,7 @@ RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection)
|
|||
if (Connection->QOS) RpcQualityOfService_Release(Connection->QOS);
|
||||
|
||||
/* server-only */
|
||||
if (Connection->server_binding) RPCRT4_DestroyBinding(Connection->server_binding);
|
||||
if (Connection->server_binding) RPCRT4_ReleaseBinding(Connection->server_binding);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, Connection);
|
||||
return RPC_S_OK;
|
||||
|
|
Loading…
Reference in New Issue