Page MenuHomeFreeBSD

ctld: Move the pidfile handle out to a global variable
ClosedPublic

Authored by jhb on Mon, Apr 20, 2:26 PM.
Tags
None
Referenced Files
F153853397: D56527.diff
Fri, Apr 24, 6:41 AM
Unknown Object (File)
Thu, Apr 23, 7:48 PM
Subscribers

Details

Summary

This ensures it will be destroyed (removing the associated pidfile)
anytime the process exits, including from exit(3) calls. This fixes
a few places that would "leak" the pidfile on certain errors.

This also removes the need for some convoluted logic where
configuration objects would hand-off ownership of the pidfile handle
from the old configuration to the new configuration.

Sponsored by: Chelsio Communications

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Mon, Apr 20, 2:26 PM

I guess this is ok, even though I normally try to avoid globals if possible. pidfile handling could also be simplified if we forbade changing the pidfile's location during a config reload. Do you think that would be acceptable to do?

This revision is now accepted and ready to land.Mon, Apr 20, 4:11 PM

I guess this is ok, even though I normally try to avoid globals if possible. pidfile handling could also be simplified if we forbade changing the pidfile's location during a config reload. Do you think that would be acceptable to do?

I have some later commits (just posted) to make some of the logic around pidfile renaming less grotty. That said, it is not at all clear to me that changing the pidfile's location is useful. I would personally be fine with just ignoring pidfile pathname changes or rejecting config files that try to use a different pidfile path than the current path.

I'm not sure we can easily get away from the global. Maybe it could be a local variable to main(), but handle_connection() still needs access to it somehow. You could make it a static member of the conf class maybe but that's really just a global with a different spelling.