Re: [Sqlrelay-discussion] Forked listener removes unix socket file (patch available)
Brought to you by:
mused
From: David M. <dav...@fi...> - 2011-11-11 05:46:05
|
I applied the fix and it's in CVS now. You're right about signal handlers setting flags and the main app testing for them and calling the shutdown code itself. That would definitely eliminate race conditions, like a signal being received before isforkedlistener is set but then the shutdown code testing isforkedlistener. I have wondered about how to deal with problems like that before. I can't believe the flag solution never occurred to me. It seems so obvious now. Feel free to work on that :) Dave On 11/11/2011 12:09 AM, Renat Sabitov wrote: > Yes, it might be a better solution. > > Yet, calling destructors and manipulating semaphores and shared memory > in signal handler is not recommended at all. The best way to handle a > signal is to fire some flag in the handler and then check it in the main > program flow. > > 11.11.2011 02:39, David Muse пишет: >> Ahhh, I see the problem... >> >> I think a cleaner solution might be to remove the setting of pidfile to >> NULL after the fork() and just wrap the removal of the pid and unixport >> files with an "if (!isforkedchild) {" in the destructor. Then the >> semset, idmemory and cmdl objects would still be freed. >> >> What do you think? >> >> Dave |