rpcrt4: Implement I_RpcGetCurrentCallHandle.

This commit is contained in:
Rob Shearman 2007-12-18 14:55:57 +00:00 committed by Alexandre Julliard
parent 1421c1a447
commit 1cb7df8a98
3 changed files with 37 additions and 8 deletions

View File

@ -187,5 +187,7 @@ RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_s
RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint);
void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection);
void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding);
RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void);
#endif

View File

@ -293,6 +293,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
exception = FALSE;
/* dispatch */
RPCRT4_SetThreadCurrentCallHandle(msg->Handle);
__TRY {
if (func) func(msg);
} __EXCEPT(rpc_filter) {
@ -304,6 +305,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
response = RPCRT4_BuildFaultHeader(msg->DataRepresentation,
RPC2NCA_STATUS(status));
} __ENDTRY
RPCRT4_SetThreadCurrentCallHandle(NULL);
if (!exception)
response = RPCRT4_BuildResponseHeader(msg->DataRepresentation,
@ -1127,6 +1129,6 @@ RPC_STATUS WINAPI RpcMgmtSetServerStackSize(ULONG ThreadStackSize)
*/
RPC_BINDING_HANDLE WINAPI I_RpcGetCurrentCallHandle(void)
{
FIXME("\n");
return NULL;
TRACE("\n");
return RPCRT4_GetThreadCurrentCallHandle();
}

View File

@ -152,6 +152,7 @@ struct threaddata
CRITICAL_SECTION cs;
DWORD thread_id;
RpcConnection *connection;
RpcBinding *server_binding;
};
/***********************************************************************
@ -188,7 +189,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
DeleteCriticalSection(&tdata->cs);
if (tdata->connection)
ERR("tdata->connection should be NULL but is still set to %p\n", tdata);
ERR("tdata->connection should be NULL but is still set to %p\n", tdata->connection);
if (tdata->server_binding)
ERR("tdata->server_binding should be NULL but is still set to %p\n", tdata->server_binding);
HeapFree(GetProcessHeap(), 0, tdata);
}
break;
@ -886,31 +889,53 @@ RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG Timeout)
return RPC_S_OK;
}
void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection)
static struct threaddata *get_or_create_threaddata(void)
{
struct threaddata *tdata = NtCurrentTeb()->ReservedForNtRpc;
if (!tdata)
{
tdata = HeapAlloc(GetProcessHeap(), 0, sizeof(*tdata));
if (!tdata) return;
tdata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*tdata));
if (!tdata) return NULL;
InitializeCriticalSection(&tdata->cs);
tdata->thread_id = GetCurrentThreadId();
tdata->connection = Connection;
EnterCriticalSection(&threaddata_cs);
list_add_tail(&threaddata_list, &tdata->entry);
LeaveCriticalSection(&threaddata_cs);
NtCurrentTeb()->ReservedForNtRpc = tdata;
return;
return tdata;
}
return tdata;
}
void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection)
{
struct threaddata *tdata = get_or_create_threaddata();
if (!tdata) return;
EnterCriticalSection(&tdata->cs);
tdata->connection = Connection;
LeaveCriticalSection(&tdata->cs);
}
void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding)
{
struct threaddata *tdata = get_or_create_threaddata();
if (!tdata) return;
tdata->server_binding = Binding;
}
RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void)
{
struct threaddata *tdata = get_or_create_threaddata();
if (!tdata) return NULL;
return tdata->server_binding;
}
/******************************************************************************
* RpcCancelThread (rpcrt4.@)
*/