/** * Function description * * @return 0 on success, otherwise a Win32 error code */ static UINT printer_free(DEVICE* device) { IRP* irp; PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device; UINT error; SetEvent(printer_dev->stopEvent); if (WaitForSingleObject(printer_dev->thread, INFINITE) == WAIT_FAILED) { error = GetLastError(); WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error); return error; } while ((irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL) irp->Discard(irp); CloseHandle(printer_dev->thread); CloseHandle(printer_dev->stopEvent); CloseHandle(printer_dev->event); _aligned_free(printer_dev->pIrpList); if (printer_dev->printer) printer_dev->printer->Free(printer_dev->printer); free(printer_dev->device.name); Stream_Free(printer_dev->device.data, TRUE); free(printer_dev); return CHANNEL_RC_OK; }
static void smartcard_free(DEVICE* dev) { IRP* irp; COMPLETIONIDINFO* CompletionIdInfo; SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) dev; SetEvent(smartcard->stopEvent); WaitForSingleObject(smartcard->thread, INFINITE); while ((irp = (IRP*) InterlockedPopEntrySList(smartcard->pIrpList)) != NULL) irp->Discard(irp); _aligned_free(smartcard->pIrpList); /* Begin TS Client defect workaround. */ while ((CompletionIdInfo = (COMPLETIONIDINFO*) list_dequeue(smartcard->CompletionIds)) != NULL) free(CompletionIdInfo); CloseHandle(smartcard->thread); CloseHandle(smartcard->irpEvent); CloseHandle(smartcard->stopEvent); CloseHandle(smartcard->CompletionIdsMutex); Stream_Free(smartcard->device.data, TRUE); list_free(smartcard->CompletionIds); /* End TS Client defect workaround. */ free(dev); }
static void serial_free(DEVICE* device) { SERIAL_DEVICE* serial = (SERIAL_DEVICE*)device; IRP* irp; DEBUG_SVC("freeing device"); freerdp_thread_stop(serial->thread); freerdp_thread_free(serial->thread); while ((irp = (IRP*)list_dequeue(serial->irp_list)) != NULL) irp->Discard(irp); list_free(serial->irp_list); while ((irp = (IRP*)list_dequeue(serial->pending_irps)) != NULL) irp->Discard(irp); list_free(serial->pending_irps); xfree(serial); }
static void parallel_free(DEVICE* device) { IRP* irp; PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) device; DEBUG_SVC("freeing device"); freerdp_thread_stop(parallel->thread); freerdp_thread_free(parallel->thread); while ((irp = (IRP*) InterlockedPopEntrySList(parallel->pIrpList)) != NULL) irp->Discard(irp); _aligned_free(parallel->pIrpList); free(parallel); }
static void parallel_free(DEVICE* device) { IRP* irp; PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) device; DEBUG_SVC("freeing device"); freerdp_thread_stop(parallel->thread); freerdp_thread_free(parallel->thread); while ((irp = (IRP*) list_dequeue(parallel->irp_list)) != NULL) irp->Discard(irp); list_free(parallel->irp_list); xfree(parallel); }
static void printer_free(DEVICE* device) { PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device; IRP* irp; freerdp_thread_stop(printer_dev->thread); freerdp_thread_free(printer_dev->thread); while ((irp = (IRP*) list_dequeue(printer_dev->irp_list)) != NULL) irp->Discard(irp); list_free(printer_dev->irp_list); if (printer_dev->printer) printer_dev->printer->Free(printer_dev->printer); xfree(printer_dev->device.name); xfree(printer_dev); }
static void printer_free(DEVICE* device) { IRP* irp; PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device; freerdp_thread_stop(printer_dev->thread); freerdp_thread_free(printer_dev->thread); while ((irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL) irp->Discard(irp); _aligned_free(printer_dev->pIrpList); if (printer_dev->printer) printer_dev->printer->Free(printer_dev->printer); free(printer_dev->device.name); free(printer_dev); }
static void drive_free(DEVICE* device) { IRP* irp; DRIVE_FILE* file; DRIVE_DEVICE* disk = (DRIVE_DEVICE*) device; SetEvent(disk->stopEvent); CloseHandle(disk->thread); CloseHandle(disk->irpEvent); while ((irp = (IRP*) InterlockedPopEntrySList(disk->pIrpList)) != NULL) irp->Discard(irp); _aligned_free(disk->pIrpList); while ((file = (DRIVE_FILE*) list_dequeue(disk->files)) != NULL) drive_file_free(file); list_free(disk->files); free(disk); }
static void scard_free(DEVICE* dev) { SCARD_DEVICE* scard = (SCARD_DEVICE*)dev; IRP* irp; COMPLETIONIDINFO* CompletionIdInfo; freerdp_thread_stop(scard->thread); freerdp_thread_free(scard->thread); while ((irp = (IRP*)list_dequeue(scard->irp_list)) != NULL) irp->Discard(irp); list_free(scard->irp_list); /* Begin TS Client defect workaround. */ while ((CompletionIdInfo = (COMPLETIONIDINFO*)list_dequeue(scard->CompletionIds)) != NULL) xfree(CompletionIdInfo); list_free(scard->CompletionIds); /* End TS Client defect workaround. */ xfree(dev); return; }