void exit_polling(void) { int i; while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) { SleepEx(0, TRUE); } if (is_polling_set) { is_polling_set = FALSE; for (i=0; i<MAX_FDS; i++) { cancel_io(i); EnterCriticalSection(&_poll_fd[i].mutex); if ( (poll_fd[i].fd > 0) && (poll_fd[i].handle != INVALID_HANDLE_VALUE) && (poll_fd[i].handle != 0) && (GetFileType(poll_fd[i].handle) == FILE_TYPE_UNKNOWN) ) { _close(poll_fd[i].fd); } free_overlapped(poll_fd[i].overlapped); if (!CancelIoEx_Available) { if (_poll_fd[i].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[i].handle); } } poll_fd[i] = INVALID_WINFD; LeaveCriticalSection(&_poll_fd[i].mutex); DeleteCriticalSection(&_poll_fd[i].mutex); } } compat_spinlock = 0; }
void exit_polling(void) { int i; while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) { SleepEx(0, TRUE); } if (is_polling_set) { is_polling_set = FALSE; for (i=0; i<MAX_FDS; i++) { // Cancel any async I/O (handle can be invalid) cancel_io(i); // If anything was pending on that I/O, it should be // terminating, and we should be able to access the fd // mutex lock before too long EnterCriticalSection(&_poll_fd[i].mutex); if ( (poll_fd[i].fd > 0) && (poll_fd[i].handle != INVALID_HANDLE_VALUE) && (poll_fd[i].handle != 0) && (GetFileType(poll_fd[i].handle) == FILE_TYPE_UNKNOWN) ) { _close(poll_fd[i].fd); } free_overlapped(poll_fd[i].overlapped); if (!CancelIoEx_Available) { // Close duplicate handle if (_poll_fd[i].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[i].handle); } } poll_fd[i] = INVALID_WINFD; LeaveCriticalSection(&_poll_fd[i].mutex); DeleteCriticalSection(&_poll_fd[i].mutex); } } compat_spinlock = 0; }
static void _free_index(int _index) { struct pipe_data *item; // Cancel any async IO (Don't care about the validity of our handles for this) cancel_io(_index); // close the duplicate handle (if we have an actual duplicate) if (Use_Duplicate_Handles) { if (_poll_fd[_index].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[_index].handle); } _poll_fd[_index].original_handle = INVALID_HANDLE_VALUE; _poll_fd[_index].thread_id = 0; if (!list_empty(&_poll_fd[_index].list)) usbi_warn(NULL, "There are some pending events in the queue"); list_for_each_entry(item, &_poll_fd[_index].list, list, struct pipe_data) { if (!item) { usbi_dbg("no item"); continue; } if (item->data) free(item->data); free(item); } } free_overlapped(poll_fd[_index].overlapped); poll_fd[_index] = INVALID_WINFD; }
void exit_polling(void) { int i; while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) { usbi_sleep(0); } if (is_polling_set) { is_polling_set = FALSE; for (i=0; i<MAX_FDS; i++) { // Cancel any async I/O (handle can be invalid) cancel_io(i); // If anything was pending on that I/O, it should be // terminating, and we should be able to access the fd // mutex lock before too long EnterCriticalSection(&_poll_fd[i].mutex); free_overlapped(poll_fd[i].overlapped); if (Use_Duplicate_Handles) { // Close duplicate handle if (_poll_fd[i].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[i].handle); } } poll_fd[i] = INVALID_WINFD; LeaveCriticalSection(&_poll_fd[i].mutex); DeleteCriticalSection(&_poll_fd[i].mutex); } } InterlockedExchange((LONG *)&compat_spinlock, 0); }
static void _free_index(int _index) { // Cancel any async IO (Don't care about the validity of our handles for this) cancel_io(_index); // close the duplicate handle (if we have an actual duplicate) if (Use_Duplicate_Handles) { if (_poll_fd[_index].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[_index].handle); } _poll_fd[_index].original_handle = INVALID_HANDLE_VALUE; _poll_fd[_index].thread_id = 0; } free_overlapped(poll_fd[_index].overlapped); poll_fd[_index] = INVALID_WINFD; }
void exit_polling(void) { struct pipe_data* item; int i; while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) { SleepEx(0, TRUE); } if (is_polling_set) { is_polling_set = FALSE; for (i=0; i<MAX_FDS; i++) { // Cancel any async I/O (handle can be invalid) cancel_io(i); // If anything was pending on that I/O, it should be // terminating, and we should be able to access the fd // mutex lock before too long EnterCriticalSection(&_poll_fd[i].mutex); free_overlapped(poll_fd[i].overlapped); if (Use_Duplicate_Handles) { // Close duplicate handle if (_poll_fd[i].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[i].handle); } } if (!list_empty(&_poll_fd[i].list)) usbi_warn(NULL, "There are some pending events in the queue"); list_for_each_entry(item, &_poll_fd[i].list, list, struct pipe_data) { if (!item) { usbi_err(NULL, "no item to free"); continue; } if (item->data) free(item->data); free(item); } poll_fd[i] = INVALID_WINFD; LeaveCriticalSection(&_poll_fd[i].mutex); DeleteCriticalSection(&_poll_fd[i].mutex); } } InterlockedExchange((LONG *)&compat_spinlock, 0); }
void _free_index(int _index) { cancel_io(_index); if ( (poll_fd[_index].handle != INVALID_HANDLE_VALUE) && (poll_fd[_index].handle != 0) && (GetFileType(poll_fd[_index].handle) == FILE_TYPE_UNKNOWN) ) { _close(poll_fd[_index].fd); } if (!CancelIoEx_Available) { if (_poll_fd[_index].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[_index].handle); } _poll_fd[_index].original_handle = INVALID_HANDLE_VALUE; _poll_fd[_index].thread_id = 0; } free_overlapped(poll_fd[_index].overlapped); poll_fd[_index] = INVALID_WINFD; }
void _free_index(int _index) { // Cancel any async IO (Don't care about the validity of our handles for this) cancel_io(_index); // close fake handle for devices if ( (poll_fd[_index].handle != INVALID_HANDLE_VALUE) && (poll_fd[_index].handle != 0) && (GetFileType(poll_fd[_index].handle) == FILE_TYPE_UNKNOWN) ) { _close(poll_fd[_index].fd); } // close the duplicate handle (if we have an actual duplicate) if (!CancelIoEx_Available) { if (_poll_fd[_index].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[_index].handle); } _poll_fd[_index].original_handle = INVALID_HANDLE_VALUE; _poll_fd[_index].thread_id = 0; } free_overlapped(poll_fd[_index].overlapped); poll_fd[_index] = INVALID_WINFD; }
mess_cdrom_driver::~mess_cdrom_driver() { cancel_io(); }