117c117 < #define WIN32_MAX_FHS 128 --- > #define WIN32_MAX_FHS 256 1473a1474,1496 > static int fdevent_check_gotone(EventLooper looper, int index) > { > EventHook hook; > > /* according to Cygwin, some objects like consoles wake up on "inappropriate" events > * like mouse movements. we need to filter these with the "check" function > */ > if ((unsigned)index < (unsigned)looper->htab_count) > { > for (hook = looper->hooks; hook; hook = hook->next) > { > if ( looper->htab[index] == hook->h && > (!hook->check || hook->check(hook)) ) > { > D( "adb_win32: signaling %s for %x\n", hook->fh->name, hook->ready ); > event_hook_signal( hook ); > return 1; > } > } > } > return 0; > } > 1521a1545 > D( "adb_win32: waiting for %d events\n", looper->htab_count ); 1525,1526d1548 < < D( "adb_win32: waiting for %d events\n", looper->htab_count ); 1528,1551c1550,1565 < D("handle count %d exceeds MAXIMUM_WAIT_OBJECTS, aborting!\n", looper->htab_count); < abort(); < } < wait_ret = WaitForMultipleObjects( looper->htab_count, looper->htab, FALSE, INFINITE ); < if (wait_ret == (int)WAIT_FAILED) { < D( "adb_win32: wait failed, error %ld\n", GetLastError() ); < } else { < D( "adb_win32: got one (index %d)\n", wait_ret ); < < /* according to Cygwin, some objects like consoles wake up on "inappropriate" events < * like mouse movements. we need to filter these with the "check" function < */ < if ((unsigned)wait_ret < (unsigned)looper->htab_count) < { < for (hook = looper->hooks; hook; hook = hook->next) < { < if ( looper->htab[wait_ret] == hook->h && < (!hook->check || hook->check(hook)) ) < { < D( "adb_win32: signaling %s for %x\n", hook->fh->name, hook->ready ); < event_hook_signal( hook ); < gotone = 1; < break; < } --- > // We need split looper->htab_count to sub items > int skip = 0; > while (!gotone && skip < looper->htab_count) { > int cnt = min(MAXIMUM_WAIT_OBJECTS, looper->htab_count - skip); > wait_ret = WaitForMultipleObjects( cnt, looper->htab + skip, FALSE, 1); > if (wait_ret == (int)WAIT_FAILED) { > D( "adb_win32: wait failed, error %ld\n", GetLastError() ); > continue; > } else if (wait_ret != (int)WAIT_TIMEOUT && > (unsigned)wait_ret < (WAIT_OBJECT_0 + cnt)) { > D( "adb_win32: got one (skip=%d, index %d)\n", skip, wait_ret ); > gotone = fdevent_check_gotone(looper, skip + (wait_ret - WAIT_OBJECT_0)); > } > if (!gotone) { > skip += cnt; > Sleep(0); 1553a1568,1578 > //D("handle count %d exceeds MAXIMUM_WAIT_OBJECTS, aborting!\n", looper->htab_count); > //abort(); > } > else { > wait_ret = WaitForMultipleObjects( looper->htab_count, looper->htab, FALSE, INFINITE ); > if (wait_ret == (int)WAIT_FAILED) { > D( "adb_win32: wait failed, error %ld\n", GetLastError() ); > } else { > D( "adb_win32: got one (index %d)\n", wait_ret ); > gotone = fdevent_check_gotone(looper, wait_ret - WAIT_OBJECT_0); > }