-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ bug ] signal handler fails to gracefully shutdown svc when worker_limit() called #354
Comments
From little I know of restbed, Firstly for worker limit, It is the count of initial threadpool that your hardware system can support. It simply means that many threads will do scheduling in case of threads running simultaneously . For best results, I use
For me this is 8 on my machine, and 2 or 4 on other machines. Setting a value higher than this, will cause the application to make more threads ready and handle service accordingly, but may also consume time. Setting a value less than concurrency limit may also slow down or not use system to the fullest. You can try to use std::async(and encapsulate the service stop here in separate thread other than main with try catch). To see which all threads it tries to close. This is the same exact behaviour when no workers are set. See whether all of the worker threads are being closed down properly. Most probably this might narrow down problem to pthread or thread library which might cause the issue in your case(from stacktrace), else the settings need to fetch workers and close down one by one. For referrence, [https://github.com/Corvusoft/restbed/blob/master/source/corvusoft/restbed/service.cpp#L113] |
@katemamba I'm not sure how your reply relates to the bug report. For clarity, let me restate:
|
Sound like a fun bug 💃. Thanks for reporting will take a look. |
The same thing also happens when |
I have the same trouble if I don't set worker_limit it works |
This was caused by the if ( m_pimpl->m_workers_stopped )
{
m_pimpl->m_workers_stopped->get( );
m_pimpl->m_workers_stopped.reset( );
} We've now implemented a timeout of 1 second if the other workers don't respond in a timely fashion. if ( m_pimpl->m_workers_stopped )
{
m_pimpl->m_workers_stopped->wait_for( seconds( 1 ) );
m_pimpl->m_workers_stopped.reset( );
} |
TLDR:
I'm using what appears to be latest (a1e9c97) code but I observe that I am unable to gracefully stop the service if settings objects has a call to
set_worker_limit()
. See sample code.Running with
./a.out 0
(no call toset_worker_limit()
) we can hit control-C and the service is shutdown.Running wtih
./a.out <anything even 0>
produces this buglinux, 4.18.14, g++ 8.2.1
code modelled after: #223
pstack of process after control-c received
The text was updated successfully, but these errors were encountered: