From 9af1a4a08ffae036384fe31032e29833381cfe03 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 23 May 2020 13:49:49 -0400 Subject: [PATCH] Fixed problem with `stop` on windows --- httplib.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index 4df9f29..6c2323e 100644 --- a/httplib.h +++ b/httplib.h @@ -45,8 +45,12 @@ #endif #ifndef CPPHTTPLIB_IDLE_INTERVAL_USECOND +#ifdef _WIN32 +#define CPPHTTPLIB_IDLE_INTERVAL_USECOND 10000 +#else #define CPPHTTPLIB_IDLE_INTERVAL_USECOND 0 #endif +#endif #ifndef CPPHTTPLIB_REQUEST_URI_MAX_LENGTH #define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192 @@ -3974,15 +3978,18 @@ inline bool Server::listen_internal() { std::unique_ptr task_queue(new_task_queue()); while (svr_sock_ != INVALID_SOCKET) { +#ifndef _WIN32 if (idle_interval_sec_ > 0 || idle_interval_usec_ > 0) { +#endif auto val = detail::select_read(svr_sock_, idle_interval_sec_, idle_interval_usec_); if (val == 0) { // Timeout task_queue->on_idle(); continue; } +#ifndef _WIN32 } - +#endif socket_t sock = accept(svr_sock_, nullptr, nullptr); if (sock == INVALID_SOCKET) {