-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
The current implementation of monitor_operation::PostAndWait prevents the call to async_monitor_thread_.join(); in shutdown_service() from finishing. PostAndWait waits on a std::condition_variable that is never notified as the lambda handler is newer run after shutdown. This prevents the thread from ever finishing.
Either remove the waiting part, or possibly do something like
void PostAndWait(const boost::system::error_code ec, const dir_monitor_event& ev) const
{
std::mutex post_mutex;
std::condition_variable post_condition_variable;
bool post_cancel = false;
this->io_service_.post(
[&]
{
handler_(ec, ev);
std::lock_guard<std::mutex> lock(post_mutex);
post_cancel = true;
post_condition_variable.notify_one();
}
);
std::unique_lock<std::mutex> lock(post_mutex);
while (!post_cancel)
{
post_condition_variable.wait_for(lock, std::chrono::milliseconds(1000));
if(this->io_service_.stopped())
break;
}
}Metadata
Metadata
Assignees
Labels
No labels