From nobody Fri Mar 03 05:17:28 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PSbnh3z1Kz3whWd; Fri, 3 Mar 2023 05:17:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PSbnh3Wqcz3lYt; Fri, 3 Mar 2023 05:17:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677820648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J7gvs4N1v7mm4CYj7IbTmSeSo6Wf5rZSk3NB9n1DfDc=; b=B2TgpO4DIq0Jq0WYHZ4031aWy/MNK0iqKZiIW6e/6tMoYzW0+PhjJB5OLFejkupvqRUJgx OQqYjR4t5RdjQOIeiorreohwsEqFDl0K10CT1qdz0OoB5dG6At1nTajC7puh9txtmr9hln 47nuxWH+ij932eQ2NEZXw21sH7wjNejj5QukwePGU1A3nJxHhO8yLvW/HGXOyPnldieeZ6 BXZbdZ0WLmSStzSALVVQMiJ0d0YYdI1FDdklTvCYp8bIjv4NRV+pX5GsnjqO7gcCdCAR3S LdCXY3W7F9n+ZUbpjQXJdUwZ+oCiGj0t4PAns3IRXtv2H10KXOQHfZLCI0NtPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677820648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J7gvs4N1v7mm4CYj7IbTmSeSo6Wf5rZSk3NB9n1DfDc=; b=ZPn54ApCT3VyVNy6mCR5n2yEa91o1qpF+Cgg8oO/vPcfPMd3VfXXqKtGmsA1LZSnyRNOSU S30rNAmCvB6EWFhQQpt1pnUMDWJeD8fURlPZUnoPHVVh7r2WMna+67XApvQjMGX1skRca2 izX0aA2t3sPly2v8ZLSGwgQHsgNbvUFfayKq/c4+TZl3CS9wUaix2wSnaCREexvjfjXuZk 31J8ZzUTDHiaJrN/ULsDktgFlKejqFz9t2fqMGSe6CCLcHgheTkp6v3hFSs/YuuvvT3UUL m8Wg7wRMMNUIMgzvvBS1Jy8aTDenW57K8cczMki8AZWTg28kmbcw1/UkwX4XRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677820648; a=rsa-sha256; cv=none; b=UEmPQ16u+2q4uf7DH2qqk1vMyG6ulbPbZMbIrb9Fhj5K71efyO206hAO69QZZBGdr7EbfK ziu6GVeLKCBLTcttDmnUYx5CNPQcZart6pWF9kPgamtijGNPjl4j4zxC+8qZv2D0L3aXyb 51eUcSH1cQ6SN0szIQ2qpMGhSYpxKdbagUEWjy/Fw7VF7hiCvx6CwcHpxnn0LI2qLMiJs3 2J8qlQCLdXzm98oPgdFi4j8Spu6NKJHh2qLW4h+T9RlDZGpvIQpiSNrKu0wterJw9BoLyw 5PXre/Z9P6U4OnYJ0W1G8Nb2hgrZ9o7ajPQPgcwVkS5F4MwQOsYotjcP54H2Zg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PSbnh2Fc1zlN2; Fri, 3 Mar 2023 05:17:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3235HSVc019694; Fri, 3 Mar 2023 05:17:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3235HScD019693; Fri, 3 Mar 2023 05:17:28 GMT (envelope-from git) Date: Fri, 3 Mar 2023 05:17:28 GMT Message-Id: <202303030517.3235HScD019693@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: e781739084e9 - main - daemon: decouple restart variable List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e781739084e9cb120ef4b6657074d2b7336ee405 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=e781739084e9cb120ef4b6657074d2b7336ee405 commit e781739084e9cb120ef4b6657074d2b7336ee405 Author: Ihor Antonov AuthorDate: 2023-03-03 05:17:02 +0000 Commit: Kyle Evans CommitDate: 2023-03-03 05:17:02 +0000 daemon: decouple restart variable The 'restart' variable was responsible for enablement of restart behavior and for restart delay. While it may seem convenient it leads to cluttering the exit/restart logic Reviewed by: kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/672 --- usr.sbin/daemon/daemon.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index d1efebd0fcc2..08ae5c74b8c2 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -147,6 +147,7 @@ main(int argc, char *argv[]) bool supervision_enabled = false; bool log_reopen = false; bool child_eof = false; + bool restart_enabled = false; char *p = NULL; const char *child_pidfile = NULL; const char *parent_pidfile = NULL; @@ -155,7 +156,7 @@ main(int argc, char *argv[]) int ch = 0; int keep_cur_workdir = 1; int pipe_fd[2] = { -1, -1 }; - int restart = 0; + int restart_delay = 1; int stdmask = STDOUT_FILENO | STDERR_FILENO; struct log_params logparams = { .syslog_enabled = false, @@ -213,11 +214,12 @@ main(int argc, char *argv[]) parent_pidfile = optarg; break; case 'r': - restart = 1; + restart_enabled = true; break; case 'R': - restart = strtol(optarg, &p, 0); - if (p == optarg || restart < 1) { + restart_enabled = true; + restart_delay = strtol(optarg, &p, 0); + if (p == optarg || restart_delay < 1) { errx(6, "invalid restart delay"); } break; @@ -303,8 +305,8 @@ main(int argc, char *argv[]) */ supervision_enabled = child_pidfile != NULL || parent_pidfile != NULL || - restart != 0 || - logparams.output_fd != -1 || + restart_enabled == true || + logparams.output_fd != -1 || logparams.syslog_enabled == true; if (supervision_enabled) { @@ -486,14 +488,14 @@ restart: } } - if (restart && !terminate) { - daemon_sleep(restart, 0); + if (restart_enabled && !terminate) { + daemon_sleep(restart_delay, 0); } if (sigprocmask(SIG_BLOCK, &mask_term, NULL)) { warn("sigprocmask"); goto exit; } - if (restart && !terminate) { + if (restart_enabled && !terminate) { close(pipe_fd[0]); pipe_fd[0] = -1; goto restart;