Re: [Cppcms-users] Segmentaion fault occurs to booster::aio::io_service running in booster::thread
Brought to you by:
artyom-beilis
From: Artyom B. <art...@gm...> - 2016-05-10 05:43:52
|
Ok I got what is the problem: Few things: I've run your code and it indeed crashes **when it runs as daemon using its internal tool** I still don't know why exactly it crashes but I assume it is related to forking. Note that threads do not go well through forking (that is required to create a daemon), actually they all become suspended and you need to wake them up - but in general it is very bad practice. IF you want to run your threads AND use daemonization services (regarding restarting of the process) you need to start your threads in cppcms::service::after_fork callback - otherwise they'll be suspended after fork. On the side note: I think cppcms needs something like daemonize that can be called prior to service::run().... something to add to feature requests. Additional problem currently unsolved: Essentially cppcms service daemonization is intended to use when cppcms::service is master loop and responsible on the application life time. For example it can even start several independent processes in prefork mode. See when you can service::run() it performs daemonization if it isn't already a daemon and in service::~service() it removes the lock file. So it is problematic to start/stop the service several times (but I think this is at least fixable) If you want to restart the service on your own - which is very legitimate requirement, for example for creating web interfaces for existing services than you can't use the internal daemonization tool. You need to fork-off and run as daemon before you start your threads & run the service. Regards, Artyom |