about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-02-10 23:17:41 +0000
committerEric Wong <normalperson@yhbt.net>2013-02-11 00:22:39 +0000
commit955991aae8c3da5a13e34e929188db3fd9216a0e (patch)
tree55f2be5437ed2d6c9ead51f9931c572e3fbbc908
parent975a329912818b49f04de15349f6414719430808 (diff)
downloadcmogstored-955991aae8c3da5a13e34e929188db3fd9216a0e.tar.gz
We don't want to be without any pidfile if writing the new
pidfile fails.
-rw-r--r--pidfile.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/pidfile.c b/pidfile.c
index 2e01c42..86e9098 100644
--- a/pidfile.c
+++ b/pidfile.c
@@ -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);