From d5930f8d9992acc0029fe80bad95d12f0f19d542 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Sun, 12 Aug 2012 13:41:38 +0800 Subject: [PATCH] libfreerdp-utils: fix wait_obj_select for Windows. --- libfreerdp-utils/wait_obj.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libfreerdp-utils/wait_obj.c b/libfreerdp-utils/wait_obj.c index a9f2e8e..c9bccf3 100644 --- a/libfreerdp-utils/wait_obj.c +++ b/libfreerdp-utils/wait_obj.c @@ -171,13 +171,12 @@ wait_obj_clear(struct wait_obj* obj) int wait_obj_select(struct wait_obj** listobj, int numobj, int timeout) { + int index; + int status; #ifndef _WIN32 int max; int sock; - int index; -#endif fd_set fds; - int status; struct timeval time; struct timeval* ptime; @@ -189,7 +188,6 @@ wait_obj_select(struct wait_obj** listobj, int numobj, int timeout) ptime = &time; } -#ifndef _WIN32 max = 0; FD_ZERO(&fds); if (listobj) @@ -205,7 +203,18 @@ wait_obj_select(struct wait_obj** listobj, int numobj, int timeout) } status = select(max + 1, &fds, 0, 0, ptime); #else - status = select(0, &fds, 0, 0, ptime); + HANDLE *hnds; + + hnds = (HANDLE *) xzalloc(sizeof(HANDLE) * (numobj + 1)); + for (index = 0; index < numobj; index++) + { + hnds[index] = listobj[index]->event; + } + + if (WaitForMultipleObjects(numobj, hnds, FALSE, timeout) == WAIT_FAILED) + status = -1; + else + status = 0; #endif return status; -- 2.7.4