From owner-svn-src-all@FreeBSD.ORG Sat Apr 14 17:35:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9FCDF1065700; Sat, 14 Apr 2012 17:35:59 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8AD4F8FC0C; Sat, 14 Apr 2012 17:35:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3EHZxcH040430; Sat, 14 Apr 2012 17:35:59 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3EHZxjb040427; Sat, 14 Apr 2012 17:35:59 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201204141735.q3EHZxjb040427@svn.freebsd.org> From: Mikolaj Golub Date: Sat, 14 Apr 2012 17:35:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234295 - stable/8/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Apr 2012 17:35:59 -0000 Author: trociny Date: Sat Apr 14 17:35:59 2012 New Revision: 234295 URL: http://svn.freebsd.org/changeset/base/234295 Log: MFC r233392, r233679: r233392: Fix typo. r233679: If hastd is invoked with "-P pidfile" option always create pidfile regardless of whether -F (foreground) option is set or not. Also, if -P option is specified, ignore pidfile setting from configuration not only on start but on reload too. This fixes the issue when for hastd run with -P option reload caused the pidfile change. Reviewed by: pjd Modified: stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/nv.c Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/hastd.c ============================================================================== --- stable/8/sbin/hastd/hastd.c Sat Apr 14 17:33:47 2012 (r234294) +++ stable/8/sbin/hastd/hastd.c Sat Apr 14 17:35:59 2012 (r234295) @@ -66,6 +66,8 @@ const char *cfgpath = HAST_CONFIG; static struct hastd_config *cfg; /* Was SIGINT or SIGTERM signal received? */ bool sigexit_received = false; +/* Path to pidfile. */ +static const char *pidfile; /* PID file handle. */ struct pidfh *pfh; /* Do we run in foreground? */ @@ -537,7 +539,8 @@ hastd_reload(void) /* * Check if pidfile's path has changed. */ - if (!foreground && strcmp(cfg->hc_pidfile, newcfg->hc_pidfile) != 0) { + if (!foreground && pidfile == NULL && + strcmp(cfg->hc_pidfile, newcfg->hc_pidfile) != 0) { newpfh = pidfile_open(newcfg->hc_pidfile, 0600, &otherpid); if (newpfh == NULL) { if (errno == EEXIST) { @@ -1163,14 +1166,12 @@ int main(int argc, char *argv[]) { struct hastd_listen *lst; - const char *pidfile; pid_t otherpid; int debuglevel; sigset_t mask; foreground = false; debuglevel = 0; - pidfile = NULL; for (;;) { int ch; @@ -1230,7 +1231,7 @@ main(int argc, char *argv[]) } } - if (!foreground) { + if (pidfile != NULL || !foreground) { pfh = pidfile_open(cfg->hc_pidfile, 0600, &otherpid); if (pfh == NULL) { if (errno == EEXIST) { @@ -1291,7 +1292,8 @@ main(int argc, char *argv[]) /* Start logging to syslog. */ pjdlog_mode_set(PJDLOG_MODE_SYSLOG); - + } + if (pidfile != NULL || !foreground) { /* Write PID to a file. */ if (pidfile_write(pfh) == -1) { pjdlog_errno(LOG_WARNING, Modified: stable/8/sbin/hastd/nv.c ============================================================================== --- stable/8/sbin/hastd/nv.c Sat Apr 14 17:33:47 2012 (r234294) +++ stable/8/sbin/hastd/nv.c Sat Apr 14 17:35:59 2012 (r234295) @@ -263,17 +263,17 @@ nv_validate(struct nv *nv, size_t *extra case NV_TYPE_UINT8: if (vsize == 0) vsize = 1; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT16: case NV_TYPE_UINT16: if (vsize == 0) vsize = 2; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT32: case NV_TYPE_UINT32: if (vsize == 0) vsize = 4; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT64: case NV_TYPE_UINT64: if (vsize == 0) @@ -290,12 +290,12 @@ nv_validate(struct nv *nv, size_t *extra case NV_TYPE_UINT16_ARRAY: if (vsize == 0) vsize = 2; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT32_ARRAY: case NV_TYPE_UINT32_ARRAY: if (vsize == 0) vsize = 4; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT64_ARRAY: case NV_TYPE_UINT64_ARRAY: if (vsize == 0) @@ -906,14 +906,14 @@ nv_swap(struct nvhdr *nvh, bool tohost) case NV_TYPE_UINT16_ARRAY: if (vsize == 0) vsize = 2; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT32: case NV_TYPE_UINT32: case NV_TYPE_INT32_ARRAY: case NV_TYPE_UINT32_ARRAY: if (vsize == 0) vsize = 4; - /* FALLTHOUGH */ + /* FALLTHROUGH */ case NV_TYPE_INT64: case NV_TYPE_UINT64: case NV_TYPE_INT64_ARRAY: