aboutsummaryrefslogtreecommitdiffstats
path: root/include/crow/http_server.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/crow/http_server.h')
-rw-r--r--include/crow/http_server.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/include/crow/http_server.h b/include/crow/http_server.h
index d5abb11..7e4da56 100644
--- a/include/crow/http_server.h
+++ b/include/crow/http_server.h
@@ -121,12 +121,19 @@ namespace crow
timer.async_wait(handler);
init_count ++;
- try
+ while(1)
{
- io_service_pool_[i]->run();
- } catch(std::exception& e)
- {
- CROW_LOG_ERROR << "Worker Crash: An uncaught exception occurred: " << e.what();
+ try
+ {
+ if (io_service_pool_[i]->run() == 0)
+ {
+ // when io_service.run returns 0, there are no more works to do.
+ break;
+ }
+ } catch(std::exception& e)
+ {
+ CROW_LOG_ERROR << "Worker Crash: An uncaught exception occurred: " << e.what();
+ }
}
}));
@@ -193,6 +200,10 @@ namespace crow
p->start();
});
}
+ else
+ {
+ delete p;
+ }
do_accept();
});
}