if (toplevel_callback_pending()) {
ticks = 0;
+ next = now;
} else if (run_timers(now, &next)) {
then = now;
now = GETTICKCOUNT();
ticks = next - now;
} else {
ticks = INFINITE;
+ /* no need to initialise next here because we can never get
+ * WAIT_TIMEOUT */
}
handles = handle_get_events(&nhandles);
int ret;
struct command_read_ctx actx, *ctx = &actx;
DWORD threadid;
+ HANDLE hThread;
fputs(prompt, stdout);
fflush(stdout);
ctx->event = CreateEvent(NULL, FALSE, FALSE, NULL);
ctx->line = NULL;
- if (!CreateThread(NULL, 0, command_read_thread,
- ctx, 0, &threadid)) {
+ hThread = CreateThread(NULL, 0, command_read_thread, ctx, 0, &threadid);
+ if (!hThread) {
+ CloseHandle(ctx->event);
fprintf(stderr, "Unable to create command input thread\n");
cleanup_exit(1);
}
assert(ret >= 0);
} while (ret == 0);
+ CloseHandle(hThread);
+ CloseHandle(ctx->event);
+
return ctx->line;
}