diff options
author | Jaeseung Ha <ipknhama@gmail.com> | 2017-09-18 00:43:42 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-18 00:43:42 +0900 |
commit | 08acc7c0bedc24bf5b8c6cc01f1701b0d45e141e (patch) | |
tree | 77aa4aa0f2cbfd139dc3194a3cf113ed2100454f /include/crow/http_server.h | |
parent | e40605da59e368be524dee0e9e9d41ef05149473 (diff) | |
parent | 194a9ef6812e3d5476419e33be2756ab69fc0696 (diff) | |
download | crow-08acc7c0bedc24bf5b8c6cc01f1701b0d45e141e.tar.gz crow-08acc7c0bedc24bf5b8c6cc01f1701b0d45e141e.zip |
Merge branch 'master' into master
Diffstat (limited to 'include/crow/http_server.h')
-rw-r--r-- | include/crow/http_server.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/include/crow/http_server.h b/include/crow/http_server.h index ab2631b..f190739 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(); + } } })); @@ -141,7 +148,8 @@ namespace crow }); } - CROW_LOG_INFO << server_name_ << " server is running at " << bindaddr_ <<":" << port_; + CROW_LOG_INFO << server_name_ << " server is running at " << bindaddr_ <<":" << port_ + << " using " << concurrency_ << " threads"; signals_.async_wait( [&](const boost::system::error_code& /*error*/, int /*signal_number*/){ @@ -193,6 +201,10 @@ namespace crow p->start(); }); } + else + { + delete p; + } do_accept(); }); } |