[Bug 284282] ctld rewrites its pidfile too often

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 22 Jan 2025 23:04:46 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284282

            Bug ID: 284282
           Summary: ctld rewrites its pidfile too often
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: asomers@FreeBSD.org

ctld rewrites its pidfile in the main_loop function.  And it will exit and
reenter that function every time that select gets interrupted by EINTR due to
SIGCHLD.  That will happen whenever a child process exits, and that will happen
every time it gets a new connection attempt.

On a production server, I saw that ctld was rewriting its pidfile about 20
times per second, due to a misconfigured iSCSI client that kept trying to
connect to a nonexistent target over and over.  Yet when the pidfile didn't
exist, a concurrent "service ctld reload" would fail.  Such a failure would
cause higher level code to restart ctld, which can cause various other
problems.

To prevent the need to restart ctld unnecessarily, the pidfile open/close logic
should be moved out of main_loop and into main.

-- 
You are receiving this mail because:
You are the assignee for the bug.