aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-12-01 11:31:37 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-12-01 15:05:57 +0300
commitdca52bf16a866de3c421402b28f277d16018ba74 (patch)
treee67ccef204e2bf3df20077bb65133c2b15532c3e
parent280fb849e0fa6524520c1dc7aed78e695ec29e8e (diff)
downloadlibmicrohttpd-dca52bf16a866de3c421402b28f277d16018ba74.tar.gz
libmicrohttpd-dca52bf16a866de3c421402b28f277d16018ba74.zip
test_client_put_stop: don't use fd_sets if select() fails
-rw-r--r--src/microhttpd/test_client_put_stop.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/microhttpd/test_client_put_stop.c b/src/microhttpd/test_client_put_stop.c
index 4a6cade0..d5589fd7 100644
--- a/src/microhttpd/test_client_put_stop.c
+++ b/src/microhttpd/test_client_put_stop.c
@@ -824,7 +824,7 @@ _MHD_dumbClient_perform (struct _MHD_dumbClient *clnt)
824 maxMhdSk = MHD_INVALID_SOCKET; 824 maxMhdSk = MHD_INVALID_SOCKET;
825 _MHD_dumbClient_get_fdsets (clnt, &maxMhdSk, &rs, &ws, &es); 825 _MHD_dumbClient_get_fdsets (clnt, &maxMhdSk, &rs, &ws, &es);
826 mhd_assert (now >= start); 826 mhd_assert (now >= start);
827 tv.tv_sec = TIMEOUTS_VAL - (now - start) + 1; 827 tv.tv_sec = TIMEOUTS_VAL * 2 - (now - start) + 1;
828 tv.tv_usec = 250 * 1000; 828 tv.tv_usec = 250 * 1000;
829 if (-1 == select (maxMhdSk + 1, &rs, &ws, &es, &tv)) 829 if (-1 == select (maxMhdSk + 1, &rs, &ws, &es, &tv))
830 { 830 {
@@ -836,14 +836,14 @@ _MHD_dumbClient_perform (struct _MHD_dumbClient *clnt)
836 (0 != es.fd_count)); 836 (0 != es.fd_count));
837 externalErrorExitDesc ("Unexpected select() error"); 837 externalErrorExitDesc ("Unexpected select() error");
838#endif /* ! MHD_POSIX_SOCKETS */ 838#endif /* ! MHD_POSIX_SOCKETS */
839 continue;
839 } 840 }
840 if (_MHD_dumbClient_process_from_fdsets (clnt, &rs, &ws, &es)) 841 if (_MHD_dumbClient_process_from_fdsets (clnt, &rs, &ws, &es))
841 return 0; 842 return 0;
842 } 843 }
843 now = time (NULL);
844 /* Use double timeout value here as MHD must catch timeout situations 844 /* Use double timeout value here as MHD must catch timeout situations
845 * in this test. Timeout in client as a last resort. */ 845 * in this test. Timeout in client as a last resort. */
846 } while (now - start <= (TIMEOUTS_VAL * 2)); 846 } while ((now = time (NULL)) - start <= (TIMEOUTS_VAL * 2));
847 return 1; 847 return 1;
848} 848}
849 849
@@ -1223,7 +1223,6 @@ static int
1223performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt) 1223performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt)
1224{ 1224{
1225 time_t start; 1225 time_t start;
1226 time_t now;
1227 struct timeval tv; 1226 struct timeval tv;
1228 int ret; 1227 int ret;
1229 const union MHD_DaemonInfo *di; 1228 const union MHD_DaemonInfo *di;
@@ -1280,6 +1279,7 @@ performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt)
1280 externalErrorExitDesc ("Unexpected select() error"); 1279 externalErrorExitDesc ("Unexpected select() error");
1281 Sleep (1); 1280 Sleep (1);
1282#endif 1281#endif
1282 continue;
1283 } 1283 }
1284 if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) 1284 if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es))
1285 mhdErrorExitDesc ("MHD_run_from_select() failed"); 1285 mhdErrorExitDesc ("MHD_run_from_select() failed");
@@ -1296,10 +1296,9 @@ performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt)
1296 clnt = NULL; 1296 clnt = NULL;
1297 } 1297 }
1298 } 1298 }
1299 now = time (NULL);
1300 /* Use double timeout value here so MHD would be able to catch timeout 1299 /* Use double timeout value here so MHD would be able to catch timeout
1301 * internally */ 1300 * internally */
1302 } while (now - start <= (TIMEOUTS_VAL * 2)); 1301 } while (time (NULL) - start <= (TIMEOUTS_VAL * 2));
1303 1302
1304 return ret; 1303 return ret;
1305} 1304}