Ejemplo n.º 1
0
static void* printer_thread_func(void* arg)
{
	IRP* irp;
	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)
	{
		DWORD rc = WaitForMultipleObjects(2, obj, FALSE, INFINITE);

		if (rc == WAIT_FAILED)
		{
			error = GetLastError();
			WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
			break;
		}

		if (rc == WAIT_OBJECT_0 + 1)
			break;
		else if (rc != WAIT_OBJECT_0)
			continue;

		ResetEvent(printer_dev->event);
		irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList);

		if (irp == NULL)
		{
			WLog_ERR(TAG, "InterlockedPopEntrySList failed!");
			error = ERROR_INTERNAL_ERROR;
			break;
		}

		if ((error = printer_process_irp(printer_dev, irp)))
		{
			WLog_ERR(TAG, "printer_process_irp failed with error %d!", error);
			break;
		}
	}

	if (error && printer_dev->rdpcontext)
		setChannelError(printer_dev->rdpcontext, error,
		                "printer_thread_func reported an error");

	ExitThread((DWORD) error);
	return NULL;
}
Ejemplo n.º 2
0
static void printer_process_irp_list(PRINTER_DEVICE* printer_dev) {
	IRP* irp;

	while (1) {
		if (freerdp_thread_is_stopped(printer_dev->thread))
			break;

		freerdp_thread_lock(printer_dev->thread);
		irp = (IRP*) list_dequeue(printer_dev->irp_list);
		freerdp_thread_unlock(printer_dev->thread);

		if (irp == NULL)
			break;

		printer_process_irp(printer_dev, irp);
	}
}
Ejemplo n.º 3
0
static void printer_process_irp_list(PRINTER_DEVICE* printer_dev)
{
    IRP* irp;

    while (1)
    {
        if (freerdp_thread_is_stopped(printer_dev->thread))
            break;

        irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList);

        if (irp == NULL)
            break;

        printer_process_irp(printer_dev, irp);
    }
}