Fix #1533 - fix iotest error on windows

This commit is contained in:
Sergey Lyubka 2022-04-22 20:53:54 +01:00
parent a7cbc19755
commit bdd7d92108
2 changed files with 8 additions and 0 deletions

View File

@ -3593,7 +3593,11 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
} }
if ((rc = select((int) maxfd + 1, &rset, &wset, NULL, &tv)) < 0) { if ((rc = select((int) maxfd + 1, &rset, &wset, NULL, &tv)) < 0) {
#if MG_ARCH == MG_ARCH_WIN32
if (maxfd == 0) Sleep(ms); // On Windows, select fails if no sockets
#else
MG_ERROR(("select: %d %d", rc, MG_SOCK_ERRNO)); MG_ERROR(("select: %d %d", rc, MG_SOCK_ERRNO));
#endif
FD_ZERO(&rset); FD_ZERO(&rset);
FD_ZERO(&wset); FD_ZERO(&wset);
} }

View File

@ -502,7 +502,11 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
} }
if ((rc = select((int) maxfd + 1, &rset, &wset, NULL, &tv)) < 0) { if ((rc = select((int) maxfd + 1, &rset, &wset, NULL, &tv)) < 0) {
#if MG_ARCH == MG_ARCH_WIN32
if (maxfd == 0) Sleep(ms); // On Windows, select fails if no sockets
#else
MG_ERROR(("select: %d %d", rc, MG_SOCK_ERRNO)); MG_ERROR(("select: %d %d", rc, MG_SOCK_ERRNO));
#endif
FD_ZERO(&rset); FD_ZERO(&rset);
FD_ZERO(&wset); FD_ZERO(&wset);
} }