svn commit: r234295 - stable/8/sbin/hastd
Mikolaj Golub
trociny at FreeBSD.org
Sat Apr 14 17:35:59 UTC 2012
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:
More information about the svn-src-stable-8
mailing list