static void* serial_thread_func(void* arg) { IRP* irp; DWORD status; SERIAL_DEVICE* serial = (SERIAL_DEVICE*)arg; HANDLE ev[] = {serial->stopEvent, Queue_Event(serial->queue)}; while (1) { status = WaitForMultipleObjects(2, ev, FALSE, 1); if (WAIT_OBJECT_0 == status) break; serial->nfds = 1; FD_ZERO(&serial->read_fds); FD_ZERO(&serial->write_fds); serial->tv.tv_sec = 0; serial->tv.tv_usec = 0; serial->select_timeout = 0; if (status == WAIT_OBJECT_0 + 1) { if ((irp = (IRP*) Queue_Dequeue(serial->queue))) serial_process_irp(serial, irp); continue; } serial_check_fds(serial); } return NULL; }
static void* irp_thread_func(void* arg) { IRP_THREAD_DATA* data = (IRP_THREAD_DATA*)arg; UINT error; /* blocks until the end of the request */ if ((error = serial_process_irp(data->serial, data->irp))) { WLog_ERR(TAG, "serial_process_irp failed with error %"PRIu32"", error); goto error_out; } EnterCriticalSection(&data->serial->TerminatingIrpThreadsLock); data->serial->IrpThreadToBeTerminatedCount++; error = data->irp->Complete(data->irp); LeaveCriticalSection(&data->serial->TerminatingIrpThreadsLock); error_out: if (error && data->serial->rdpcontext) setChannelError(data->serial->rdpcontext, error, "irp_thread_func reported an error"); /* NB: At this point, the server might already being reusing * the CompletionId whereas the thread is not yet * terminated */ free(data); ExitThread((DWORD)error); return NULL; }
static void serial_process_irp_list(SERIAL_DEVICE* serial) { IRP* irp; while (1) { if (freerdp_thread_is_stopped(serial->thread)) break; freerdp_thread_lock(serial->thread); irp = (IRP*)list_dequeue(serial->irp_list); freerdp_thread_unlock(serial->thread); if (irp == NULL) break; serial_process_irp(serial, irp); } }
static void* serial_thread_func(void* arg) { IRP* irp; DWORD status; SERIAL_DEVICE* serial = (SERIAL_DEVICE*)arg; while (1) { if (WaitForSingleObject(serial->stopEvent, 0) == WAIT_OBJECT_0) break; if (WaitForSingleObject(Queue_Event(serial->queue), 10) == WAIT_OBJECT_0) break; serial->nfds = 1; FD_ZERO(&serial->read_fds); FD_ZERO(&serial->write_fds); serial->tv.tv_sec = 1; serial->tv.tv_usec = 0; serial->select_timeout = 0; irp = (IRP*) Queue_Dequeue(serial->queue); if (irp) serial_process_irp(serial, irp); status = WaitForSingleObject(serial->in_event, 0); if ((status == WAIT_OBJECT_0) || (status == WAIT_TIMEOUT)) { if (serial_check_fds(serial)) ResetEvent(serial->in_event); } } return NULL; }
static void* serial_thread_func(void* arg) { IRP* irp; DWORD status; SERIAL_DEVICE* serial = (SERIAL_DEVICE*)arg; HANDLE ev[] = {serial->stopEvent, Queue_Event(serial->queue), serial->newEvent}; assert(NULL != serial); while (1) { status = WaitForMultipleObjects(3, ev, FALSE, INFINITE); if (WAIT_OBJECT_0 == status) break; else if (status == WAIT_OBJECT_0 + 1) { FD_ZERO(&serial->read_fds); FD_ZERO(&serial->write_fds); serial->tv.tv_sec = 0; serial->tv.tv_usec = 0; serial->select_timeout = 0; if ((irp = (IRP*) Queue_Dequeue(serial->queue))) serial_process_irp(serial, irp); } else if (status == WAIT_OBJECT_0 + 2) ResetEvent(serial->newEvent); if(serial->tty) serial_check_fds(serial); } ExitThread(0); return NULL; }