[AGENT++] proper way to shutdown an agent
Mo Po
mopo777 at gmail.com
Tue Jun 7 20:44:22 CEST 2011
On 06/07/2011 11:37 AM, Jochen Katz wrote:
> Hi,
>
>> I am getting a core dump when the agent exits (is shut down), such as in:
>>
>> I suspect the problem is that the above get bulk requests is still
>> being processed (asynchronously) while the application is exiting and
>> destructors are called.
>
> yes, you are right.
>
>> What is the proper way to shut down a multi-threaded agent?
>
> Add the following code after the main loop:
>
> #ifdef AGENTPP_USE_THREAD_POOL
> ThreadPool *threadPool = mib->get_thread_pool();
> if (threadPool)
> {
> int loops = 0;
> while (!threadPool->is_idle())
> {
> Thread::sleep(500);
> loops++;
> if (loops> 10)
> {
> LOG_BEGIN(loggerModuleName, INFO_LOG | 1);
> LOG("Still waiting for active requests to finish");
> LOG_END;
> loops = 0;
> }
> }
> }
> #endif
Jochen,
Thanks a lot!
So I gather that checking e.g. request_list-is_empty() is not enough,
and I should use the code above, right?
Regards.
Mo Po
>
> Regards,
> Jochen
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/agentpp
More information about the AGENTPP
mailing list