Commit 1cb7df8a authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Implement I_RpcGetCurrentCallHandle.

parent 1421c1a4
...@@ -187,5 +187,7 @@ RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_s ...@@ -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); 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_SetThreadCurrentConnection(RpcConnection *Connection);
void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding);
RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void);
#endif #endif
...@@ -293,6 +293,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA ...@@ -293,6 +293,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
exception = FALSE; exception = FALSE;
/* dispatch */ /* dispatch */
RPCRT4_SetThreadCurrentCallHandle(msg->Handle);
__TRY { __TRY {
if (func) func(msg); if (func) func(msg);
} __EXCEPT(rpc_filter) { } __EXCEPT(rpc_filter) {
...@@ -304,6 +305,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA ...@@ -304,6 +305,7 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
response = RPCRT4_BuildFaultHeader(msg->DataRepresentation, response = RPCRT4_BuildFaultHeader(msg->DataRepresentation,
RPC2NCA_STATUS(status)); RPC2NCA_STATUS(status));
} __ENDTRY } __ENDTRY
RPCRT4_SetThreadCurrentCallHandle(NULL);
if (!exception) if (!exception)
response = RPCRT4_BuildResponseHeader(msg->DataRepresentation, response = RPCRT4_BuildResponseHeader(msg->DataRepresentation,
...@@ -1127,6 +1129,6 @@ RPC_STATUS WINAPI RpcMgmtSetServerStackSize(ULONG ThreadStackSize) ...@@ -1127,6 +1129,6 @@ RPC_STATUS WINAPI RpcMgmtSetServerStackSize(ULONG ThreadStackSize)
*/ */
RPC_BINDING_HANDLE WINAPI I_RpcGetCurrentCallHandle(void) RPC_BINDING_HANDLE WINAPI I_RpcGetCurrentCallHandle(void)
{ {
FIXME("\n"); TRACE("\n");
return NULL; return RPCRT4_GetThreadCurrentCallHandle();
} }
...@@ -152,6 +152,7 @@ struct threaddata ...@@ -152,6 +152,7 @@ struct threaddata
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
DWORD thread_id; DWORD thread_id;
RpcConnection *connection; RpcConnection *connection;
RpcBinding *server_binding;
}; };
/*********************************************************************** /***********************************************************************
...@@ -188,7 +189,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -188,7 +189,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
DeleteCriticalSection(&tdata->cs); DeleteCriticalSection(&tdata->cs);
if (tdata->connection) 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); HeapFree(GetProcessHeap(), 0, tdata);
} }
break; break;
...@@ -886,31 +889,53 @@ RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG Timeout) ...@@ -886,31 +889,53 @@ RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG Timeout)
return RPC_S_OK; return RPC_S_OK;
} }
void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection) static struct threaddata *get_or_create_threaddata(void)
{ {
struct threaddata *tdata = NtCurrentTeb()->ReservedForNtRpc; struct threaddata *tdata = NtCurrentTeb()->ReservedForNtRpc;
if (!tdata) if (!tdata)
{ {
tdata = HeapAlloc(GetProcessHeap(), 0, sizeof(*tdata)); tdata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*tdata));
if (!tdata) return; if (!tdata) return NULL;
InitializeCriticalSection(&tdata->cs); InitializeCriticalSection(&tdata->cs);
tdata->thread_id = GetCurrentThreadId(); tdata->thread_id = GetCurrentThreadId();
tdata->connection = Connection;
EnterCriticalSection(&threaddata_cs); EnterCriticalSection(&threaddata_cs);
list_add_tail(&threaddata_list, &tdata->entry); list_add_tail(&threaddata_list, &tdata->entry);
LeaveCriticalSection(&threaddata_cs); LeaveCriticalSection(&threaddata_cs);
NtCurrentTeb()->ReservedForNtRpc = tdata; 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); EnterCriticalSection(&tdata->cs);
tdata->connection = Connection; tdata->connection = Connection;
LeaveCriticalSection(&tdata->cs); 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.@) * RpcCancelThread (rpcrt4.@)
*/ */
......
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