shaneharter / PHP-Daemon

Build production-ready Daemons using PHP 5.3+. Build fault-tolerant applications without the boilerplate.
Other
767 stars 134 forks source link

Daemon not destroying msg_queue and shm when restarting #48

Open brunnels opened 10 years ago

brunnels commented 10 years ago

I thought I had reported this issue before but I can't find it now.

To reproduce run in daemon mode and set a low $auto_restart_interval. Every time the daemon restarts it creates a new msg_queue and new shm mallocs for each worker. This will quickly eat up all your memory and the daemon will eventually be unable to restart.

brunnels commented 10 years ago

Can reproduce this problem with the PrimeNumbers example. Start it, hit ctrl-c, wait for it all to die, run ipcs and see there was one shm segment created and one message queue created and they are still there, run example and kill it again, run ipcs and see there are now 2 segments and 2 queues.

There is the mechanism in the mediator destruct method to check for pending messages and if none it calls the release method on the via. Even if I comment out the queue message check there the shm segment and queue are not removed.

I'll continue to investigate and find a solution because this is a pain point for me right now as I'm having to babysit the daemon process to ensure it stays running.