Skip to content

Commit

Permalink
Fixed problem with stop on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed May 23, 2020
1 parent 0654e5d commit 9af1a4a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3974,15 +3978,18 @@ inline bool Server::listen_internal() {
std::unique_ptr<TaskQueue> 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) {
Expand Down

0 comments on commit 9af1a4a

Please sign in to comment.