- if (!rc) {
- for (i = 0; i < 2 * td->o.iodepth; i++) {
- /* Create a manual-reset event for putting in OVERLAPPED */
- wd->io_handles[i] = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (wd->io_handles[i] == NULL) {
- PrintError(__func__);
- rc = 1;
- break;
- }
+ f->hFile = INVALID_HANDLE_VALUE;
+ return rc;
+}
+
+static BOOL timeout_expired(DWORD start_count, DWORD end_count)
+{
+ BOOL expired = FALSE;
+ DWORD current_time;
+
+ current_time = GetTickCount();
+
+ if ((end_count > start_count) && current_time >= end_count)
+ expired = TRUE;
+ else if (current_time < start_count && current_time > end_count)
+ expired = TRUE;
+
+ return expired;
+}
+
+static struct io_u* fio_windowsaio_event(struct thread_data *td, int event)
+{
+ struct windowsaio_data *wd = td->io_ops_data;
+ return wd->aio_events[event];
+}
+
+static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min,
+ unsigned int max,
+ const struct timespec *t)
+{
+ struct windowsaio_data *wd = td->io_ops_data;
+ unsigned int dequeued = 0;
+ struct io_u *io_u;
+ int i;
+ struct fio_overlapped *fov;
+ DWORD start_count = 0;
+ DWORD end_count = 0;
+ DWORD status;
+ DWORD mswait = 250;
+
+ if (t != NULL) {
+ mswait = (t->tv_sec * 1000) + (t->tv_nsec / 1000000);
+ start_count = GetTickCount();
+ end_count = start_count + (t->tv_sec * 1000) + (t->tv_nsec / 1000000);
+ }
+
+ do {
+ io_u_qiter(&td->io_u_all, io_u, i) {
+ if (!(io_u->flags & IO_U_F_FLIGHT))
+ continue;
+
+ fov = (struct fio_overlapped*)io_u->engine_data;
+
+ if (fov->io_complete) {
+ fov->io_complete = FALSE;
+ wd->aio_events[dequeued] = io_u;
+ dequeued++;