diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-02-10 23:17:41 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-02-11 00:22:39 +0000 |
commit | 955991aae8c3da5a13e34e929188db3fd9216a0e (patch) | |
tree | 55f2be5437ed2d6c9ead51f9931c572e3fbbc908 | |
parent | 975a329912818b49f04de15349f6414719430808 (diff) | |
download | cmogstored-955991aae8c3da5a13e34e929188db3fd9216a0e.tar.gz |
We don't want to be without any pidfile if writing the new pidfile fails.
-rw-r--r-- | pidfile.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -282,9 +282,6 @@ void mog_pidfile_upgrade_abort(void) /* ensure the pidfile of the upgraded process is really invalid */ if (!upgrade_failed()) return; - if (!unlink_if_owner_or_unused(old)) - return; - mog_free_and_null(&old); fd = open(pidfile, O_TRUNC|O_CREAT|O_WRONLY|O_CLOEXEC, 0666); if (fd >= 0) { @@ -292,7 +289,8 @@ void mog_pidfile_upgrade_abort(void) if (!pid_write(fd)) syslog(LOG_ERR, "failed to write %s: %m", pidfile); mog_close(fd); - mog_free_and_null(&old); + if (unlink_if_owner_or_unused(old)) + mog_free_and_null(&old); } else { /* we're pidless(!) */ syslog(LOG_ERR, "failed to open %s for writing: %m", pidfile); |