Commit 8aeb2858 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Add a reference to the binding object in I_RpcNegotiateTransferSyntax…

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.
parent c7f9b934
...@@ -249,14 +249,12 @@ RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) ...@@ -249,14 +249,12 @@ RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection)
return RPC_S_OK; return RPC_S_OK;
} }
RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding) void RPCRT4_AddRefBinding(RpcBinding* Binding)
{ {
InterlockedIncrement(&OldBinding->refs); InterlockedIncrement(&Binding->refs);
*Binding = OldBinding;
return RPC_S_OK;
} }
RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding) RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding)
{ {
if (InterlockedDecrement(&Binding->refs)) if (InterlockedDecrement(&Binding->refs))
return RPC_S_OK; return RPC_S_OK;
...@@ -661,7 +659,7 @@ RPC_STATUS WINAPI RpcBindingFree( RPC_BINDING_HANDLE* Binding ) ...@@ -661,7 +659,7 @@ RPC_STATUS WINAPI RpcBindingFree( RPC_BINDING_HANDLE* Binding )
{ {
RPC_STATUS status; RPC_STATUS status;
TRACE("(%p) = %p\n", Binding, *Binding); TRACE("(%p) = %p\n", Binding, *Binding);
status = RPCRT4_DestroyBinding(*Binding); status = RPCRT4_ReleaseBinding(*Binding);
if (status == RPC_S_OK) *Binding = 0; if (status == RPC_S_OK) *Binding = 0;
return status; return status;
} }
...@@ -741,7 +739,7 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingA( RPC_CSTR StringBinding, RPC_BIND ...@@ -741,7 +739,7 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingA( RPC_CSTR StringBinding, RPC_BIND
if (ret == RPC_S_OK) if (ret == RPC_S_OK)
*Binding = (RPC_BINDING_HANDLE)bind; *Binding = (RPC_BINDING_HANDLE)bind;
else else
RPCRT4_DestroyBinding(bind); RPCRT4_ReleaseBinding(bind);
return ret; return ret;
} }
...@@ -780,7 +778,7 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingW( RPC_WSTR StringBinding, RPC_BIND ...@@ -780,7 +778,7 @@ RPC_STATUS WINAPI RpcBindingFromStringBindingW( RPC_WSTR StringBinding, RPC_BIND
if (ret == RPC_S_OK) if (ret == RPC_S_OK)
*Binding = (RPC_BINDING_HANDLE)bind; *Binding = (RPC_BINDING_HANDLE)bind;
else else
RPCRT4_DestroyBinding(bind); RPCRT4_ReleaseBinding(bind);
return ret; return ret;
} }
......
...@@ -145,8 +145,8 @@ RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* Old ...@@ -145,8 +145,8 @@ RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* Old
RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint); RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint);
RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid); RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid);
RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection); RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection);
RPC_STATUS RPCRT4_ExportBinding(RpcBinding** Binding, RpcBinding* OldBinding); void RPCRT4_AddRefBinding(RpcBinding* Binding);
RPC_STATUS RPCRT4_DestroyBinding(RpcBinding* Binding); RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding);
RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId); const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId);
RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection); RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection);
......
...@@ -1017,7 +1017,10 @@ RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax(PRPC_MESSAGE pMsg) ...@@ -1017,7 +1017,10 @@ RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax(PRPC_MESSAGE pMsg)
&cif->InterfaceId); &cif->InterfaceId);
if (status == RPC_S_OK) if (status == RPC_S_OK)
{
pMsg->ReservedForRuntime = conn; pMsg->ReservedForRuntime = conn;
RPCRT4_AddRefBinding(bind);
}
} }
return status; return status;
...@@ -1114,6 +1117,7 @@ RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg) ...@@ -1114,6 +1117,7 @@ RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
{ {
RpcConnection *conn = pMsg->ReservedForRuntime; RpcConnection *conn = pMsg->ReservedForRuntime;
RPCRT4_CloseBinding(bind, conn); RPCRT4_CloseBinding(bind, conn);
RPCRT4_ReleaseBinding(bind);
pMsg->ReservedForRuntime = NULL; pMsg->ReservedForRuntime = NULL;
} }
I_RpcFree(pMsg->Buffer); I_RpcFree(pMsg->Buffer);
......
...@@ -1551,7 +1551,7 @@ RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection) ...@@ -1551,7 +1551,7 @@ RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection)
if (Connection->QOS) RpcQualityOfService_Release(Connection->QOS); if (Connection->QOS) RpcQualityOfService_Release(Connection->QOS);
/* server-only */ /* server-only */
if (Connection->server_binding) RPCRT4_DestroyBinding(Connection->server_binding); if (Connection->server_binding) RPCRT4_ReleaseBinding(Connection->server_binding);
HeapFree(GetProcessHeap(), 0, Connection); HeapFree(GetProcessHeap(), 0, Connection);
return RPC_S_OK; return RPC_S_OK;
......
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