channels: remove thread-local storage usage

This commit is contained in:
Marc-André Moreau 2016-11-15 11:41:01 -05:00
parent 2cce8e9fbc
commit dee76617d9
26 changed files with 14 additions and 64 deletions

View File

@ -230,7 +230,7 @@ static void* audin_alsa_thread_func(void* arg)
AudinALSADevice* alsa = (AudinALSADevice*) arg;
DWORD status;
DEBUG_DVC("in");
freerdp_channel_init_thread_context(alsa->rdpcontext);
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel;
buffer = (BYTE*) calloc(1, rbytes_per_frame * alsa->frames_per_packet);

View File

@ -190,8 +190,6 @@ static void* audin_oss_thread_func(void* arg)
goto err_out;
}
freerdp_channel_init_thread_context(oss->rdpcontext);
if (oss->dev_unit != -1)
{
sprintf_s(dev_name, (PATH_MAX - 1), "/dev/dsp%i", oss->dev_unit);

View File

@ -417,7 +417,6 @@ static void* audin_server_thread_func(void* arg)
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
freerdp_channel_init_thread_context(audin->context.rdpcontext);
if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualEventHandle, &buffer,
&BytesReturned) == TRUE)

View File

@ -1052,7 +1052,6 @@ static void* cliprdr_virtual_channel_client_thread(void* arg)
wMessage message;
cliprdrPlugin* cliprdr = (cliprdrPlugin*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(cliprdr->context->rdpcontext);
while (1)
{

View File

@ -1328,7 +1328,7 @@ static void* cliprdr_server_thread(void* arg)
CliprdrServerContext* context = (CliprdrServerContext*) arg;
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
UINT error;
freerdp_channel_init_thread_context(context->rdpcontext);
ChannelEvent = context->GetEventHandle(context);
nCount = 0;
events[nCount++] = cliprdr->StopEvent;

View File

@ -49,7 +49,7 @@ static void* drdynvc_server_thread(void* arg)
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
freerdp_channel_init_thread_context(context->rdpcontext);
s = Stream_New(NULL, 4096);
if (!s)

View File

@ -683,7 +683,6 @@ static void* drive_thread_func(void* arg)
wMessage message;
DRIVE_DEVICE* drive = (DRIVE_DEVICE*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(drive->rdpcontext);
while (1)
{

View File

@ -117,7 +117,6 @@ static void* echo_server_thread_func(void* arg)
echo_server* echo = (echo_server*) arg;
UINT error;
DWORD status;
freerdp_channel_init_thread_context(echo->context.rdpcontext);
if ((error = echo_server_open_channel(echo)))
{

View File

@ -1045,7 +1045,7 @@ static void* encomsp_virtual_channel_client_thread(void* arg)
wMessage message;
encomspPlugin* encomsp = (encomspPlugin*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(encomsp->rdpcontext);
encomsp_process_connect(encomsp);
while (1)

View File

@ -187,7 +187,7 @@ static void* encomsp_server_thread(void* arg)
UINT error = CHANNEL_RC_OK;
DWORD status;
context = (EncomspServerContext*) arg;
freerdp_channel_init_thread_context(context->rdpcontext);
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;

View File

@ -310,7 +310,6 @@ static void* parallel_thread_func(void* arg)
wMessage message;
PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(parallel->rdpcontext);
while (1)
{

View File

@ -237,7 +237,6 @@ static void* printer_thread_func(void* arg)
PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) arg;
HANDLE obj[] = {printer_dev->event, printer_dev->stopEvent};
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(printer_dev->rdpcontext);
while (1)
{

View File

@ -586,7 +586,6 @@ static void* rail_virtual_channel_client_thread(void* arg)
wMessage message;
railPlugin* rail = (railPlugin*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(rail->rdpcontext);
while (1)
{

View File

@ -864,7 +864,6 @@ static void* drive_hotplug_thread_func(void* arg)
UINT error = 0;
DWORD status;
rdpdr = (rdpdrPlugin*) arg;
freerdp_channel_init_thread_context(rdpdr->rdpcontext);
if (!(rdpdr->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
{
@ -1563,8 +1562,6 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
return NULL;
}
freerdp_channel_init_thread_context(rdpdr->rdpcontext);
if ((error = rdpdr_process_connect(rdpdr)))
{
WLog_ERR(TAG, "rdpdr_process_connect failed with error %lu!", error);

View File

@ -1151,7 +1151,7 @@ static void* rdpdr_server_thread(void* arg)
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
freerdp_channel_init_thread_context(context->rdpcontext);
s = Stream_New(NULL, 4096);
if (!s)

View File

@ -176,7 +176,6 @@ static void* rdpei_schedule_thread(void* arg)
RdpeiClientContext* context = (RdpeiClientContext*) rdpei->iface.pInterface;
HANDLE hdl[] = {rdpei->event, rdpei->stopEvent};
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(rdpei->rdpcontext);
if (!rdpei)
{

View File

@ -1335,7 +1335,7 @@ static void* rdpgfx_server_thread_func(void* arg)
buffer = NULL;
BytesReturned = 0;
nCount = 0;
freerdp_channel_init_thread_context(context->rdpcontext);
events[nCount++] = priv->stopEvent;
events[nCount++] = priv->channelEvent;

View File

@ -113,7 +113,7 @@ static void* rdpsnd_schedule_thread(void* arg)
HANDLE events[2];
UINT error = CHANNEL_RC_OK;
DWORD status;
freerdp_channel_init_thread_context(rdpsnd->rdpcontext);
events[0] = MessageQueue_Event(rdpsnd->MsgPipe->Out);
events[1] = rdpsnd->stopEvent;
@ -1247,7 +1247,6 @@ static void* rdpsnd_virtual_channel_client_thread(void* arg)
wMessage message;
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) arg;
UINT error;
freerdp_channel_init_thread_context(rdpsnd->rdpcontext);
if ((error = rdpsnd_process_connect(rdpsnd)))
{

View File

@ -246,7 +246,7 @@ static void* rdpsnd_server_thread(void* arg)
RdpsndServerContext* context;
UINT error = CHANNEL_RC_OK;
context = (RdpsndServerContext*)arg;
freerdp_channel_init_thread_context(context->rdpcontext);
nCount = 0;
events[nCount++] = context->priv->channelEvent;
events[nCount++] = context->priv->StopEvent;

View File

@ -848,7 +848,7 @@ static void* remdesk_virtual_channel_client_thread(void* arg)
wMessage message;
remdeskPlugin* remdesk = (remdeskPlugin*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(remdesk->rdpcontext);
remdesk_process_connect(remdesk);
while (1)

View File

@ -592,7 +592,7 @@ static void* remdesk_server_thread(void* arg)
RemdeskServerContext* context;
UINT error;
context = (RemdeskServerContext*) arg;
freerdp_channel_init_thread_context(context->rdpcontext);
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;

View File

@ -462,7 +462,6 @@ static void* irp_thread_func(void* arg)
{
IRP_THREAD_DATA* data = (IRP_THREAD_DATA*)arg;
UINT error;
freerdp_channel_init_thread_context(data->serial->rdpcontext);
/* blocks until the end of the request */
if ((error = serial_process_irp(data->serial, data->irp)))
@ -680,7 +679,6 @@ static void* serial_thread_func(void* arg)
wMessage message;
SERIAL_DEVICE* serial = (SERIAL_DEVICE*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(serial->rdpcontext);
while (1)
{

View File

@ -45,7 +45,7 @@ void* smartcard_context_thread(SMARTCARD_CONTEXT* pContext)
SMARTCARD_OPERATION* operation;
UINT error = CHANNEL_RC_OK;
smartcard = pContext->smartcard;
freerdp_channel_init_thread_context(smartcard->rdpcontext);
nCount = 0;
hEvents[nCount++] = MessageQueue_Event(pContext->IrpQueue);
@ -516,7 +516,7 @@ static void* smartcard_thread_func(void* arg)
wMessage message;
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) arg;
UINT error = CHANNEL_RC_OK;
freerdp_channel_init_thread_context(smartcard->rdpcontext);
nCount = 0;
hEvents[nCount++] = MessageQueue_Event(smartcard->IrpQueue);
hEvents[nCount++] = Queue_Event(smartcard->CompletedIrpQueue);

View File

@ -718,7 +718,7 @@ static void* tsmf_stream_ack_func(void* arg)
TSMF_STREAM* stream = (TSMF_STREAM*) arg;
UINT error = CHANNEL_RC_OK;
DEBUG_TSMF("in %d", stream->stream_id);
freerdp_channel_init_thread_context(stream->rdpcontext);
hdl[0] = stream->stopEvent;
hdl[1] = Queue_Event(stream->sample_ack_list);
@ -806,7 +806,6 @@ static void* tsmf_stream_playback_func(void* arg)
UINT error = CHANNEL_RC_OK;
DWORD status;
DEBUG_TSMF("in %d", stream->stream_id);
freerdp_channel_init_thread_context(stream->rdpcontext);
if (stream->major_type == TSMF_MAJOR_TYPE_AUDIO &&
stream->sample_rate && stream->channels && stream->bits_per_sample)

View File

@ -307,10 +307,6 @@ FREERDP_API BOOL freerdp_shall_disconnect(freerdp* instance);
FREERDP_API BOOL freerdp_disconnect(freerdp* instance);
FREERDP_API BOOL freerdp_reconnect(freerdp* instance);
FREERDP_API void freerdp_channel_init_thread_context(rdpContext* context);
FREERDP_API freerdp* freerdp_channel_get_instance(void);
FREERDP_API rdpContext* freerdp_channel_get_context(void);
FREERDP_API UINT freerdp_channel_add_init_handle_data(rdpChannelHandles* handles, void* pInitHandle, void* pUserData);
FREERDP_API void* freerdp_channel_get_init_handle_data(rdpChannelHandles* handles, void* pInitHandle);
FREERDP_API void freerdp_channel_remove_init_handle_data(rdpChannelHandles* handles, void* pInitHandle);

View File

@ -51,34 +51,6 @@
/* connectErrorCode is 'extern' in error.h. See comment there.*/
/* Thread local storage variables.
* They need to be initialized in every thread that
* has to use them. */
static WINPR_TLS rdpContext* s_TLSContext = NULL;
void freerdp_channel_init_thread_context(rdpContext* context)
{
s_TLSContext = context;
}
freerdp* freerdp_channel_get_instance(void)
{
if (!s_TLSContext)
{
WLog_ERR(TAG,
"Funcion was called from thread that did not call freerdp_channel_init_thread_context");
winpr_log_backtrace(TAG, WLOG_ERROR, 20);
return NULL;
}
return s_TLSContext->instance;
}
rdpContext* freerdp_channel_get_context(void)
{
return s_TLSContext;
}
UINT freerdp_channel_add_init_handle_data(rdpChannelHandles* handles, void* pInitHandle, void* pUserData)
{
if (!handles->init)
@ -181,7 +153,6 @@ BOOL freerdp_connect(freerdp* instance)
if (!instance)
return FALSE;
freerdp_channel_init_thread_context(instance->context);
/* We always set the return code to 0 before we start the connect sequence*/
connectErrorCode = 0;
freerdp_set_last_error(instance->context, FREERDP_ERROR_SUCCESS);