Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bebuch committed Apr 9, 2018
1 parent cf2527f commit 19ee1fa
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ namespace disposer_module::http_server_component{
, interval_(component_("min_interval_in_ms"_param)) {}

~running_chains(){
wait_on_last_async();
}

void wait_on_last_async(){
// As long as async calls are pending
while(async_calls_ > 0){
// Request the server to run a handler async
Expand All @@ -190,6 +194,7 @@ namespace disposer_module::http_server_component{
}
}


void add(
std::string const& chain,
std::optional< std::size_t > exec_count = {}
Expand Down Expand Up @@ -236,6 +241,8 @@ namespace disposer_module::http_server_component{
return;
}

if(chains_.empty()) return;

timer_.expires_after(interval_);
timer_.async_wait(
[this, lock = webservice::async_lock(async_calls_)](
Expand Down Expand Up @@ -271,9 +278,15 @@ namespace disposer_module::http_server_component{


void on_shutdown()noexcept final{
std::lock_guard lock(mutex_);
std::unique_lock lock(mutex_);
shutdown_ = true;
lock.unlock();

timer_.cancel();

wait_on_last_async();

lock.lock();
for(auto& pair: chains_){
lockless_erase(pair.first);
}
Expand Down

0 comments on commit 19ee1fa

Please sign in to comment.