diff options
author | ipknHama <ipknhama@gmail.com> | 2017-09-17 12:44:15 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2017-09-17 12:45:13 +0900 |
commit | 69a17f066be71d590f1247ed5c70c2b67eff3b2d (patch) | |
tree | 03c3793a3ca14b09e08fb8db7c9d8418512a69fd /include | |
parent | 2564c62778b1271f830dc4ad551f8804df6010f8 (diff) | |
download | crow-69a17f066be71d590f1247ed5c70c2b67eff3b2d.tar.gz crow-69a17f066be71d590f1247ed5c70c2b67eff3b2d.zip |
Fix #245. Trying to keep serving after an exception in the handler.
Diffstat (limited to 'include')
-rw-r--r-- | include/crow/http_server.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/include/crow/http_server.h b/include/crow/http_server.h index d5abb11..a247b12 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(); + } } })); |