[Bug 271460] ctld ports become inaccessible due to concurrent service restarts

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 19 Sep 2024 01:28:06 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271460

--- Comment #4 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=5f89aea7b74aa4605b25af62e31303097a4a48cc

commit 5f89aea7b74aa4605b25af62e31303097a4a48cc
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2024-08-07 15:21:08 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2024-09-18 20:06:31 +0000

    ctld: fix several process setup/teardown bugs

    All of the below bugs could result in a system where ctld is not
    running, but LUNs and targets still exist in the kernel; a difficult
    situation to recover from.

    * open the pidfile earlier.  Open the pidfile before reading the
      kernel's current state, so two racing ctld processes won't step on
      each others' toes.

    * close the pidfile later.  Close it after tearing down the
      configuration, for the same reason.

    * If the configured pidfile changes, then rename it on SIGHUP rather
      than remove and recreate it.

    * When running in debug mode, don't close the pidfile while handling a
      new connection.  Only do that in non-debug mode, in the child of the
      fork.

    * Register signal handlers earlier.  Otherwise a SIGTERM signal received
      during startup could kill ctld without tearing down the configuration.

    MFC after:      2 weeks
    PR:             271460
    Sponsored by:   Axcient
    Reviewed by:    mav
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1370

 usr.sbin/ctld/ctld.c | 70 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 30 deletions(-)

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