From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@gmail.com>
Subject: [PATCH 08/17] multipathd: fail if pidfile can't be created
Date: Mon, 28 Mar 2016 22:13:05 -0500 [thread overview]
Message-ID: <1459221194-23222-9-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1459221194-23222-1-git-send-email-bmarzins@redhat.com>
Right now, multipathd ignores failures from pidfile_create. This means
that multiple multipathd processes can be running at the same time. If
someone runs "multipathd" and doesn't add a command after it, a new
process will be created, even if one is already running. To avoid this,
multipathd needs to actually fail if the pidfile can't be created or
locked. Since we only really need the pidfile to keep from launching
multiple processes, we can create in earlier in startup. This patch
moves pidfile_create to as soon as we can be sure that we can log an
error message, and fails multipathd if the create fails.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/main.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index 8f4fb58..06876b9 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1768,7 +1768,7 @@ child (void * param)
#ifdef USE_SYSTEMD
unsigned long checkint;
#endif
- int rc, pid_rc;
+ int rc;
char *envp;
mlockall(MCL_CURRENT | MCL_FUTURE);
@@ -1786,6 +1786,12 @@ child (void * param)
log_thread_start(&log_attr);
pthread_attr_destroy(&log_attr);
}
+ if (pidfile_create(DEFAULT_PIDFILE, daemon_pid)) {
+ condlog(1, "failed to create pidfile");
+ if (logsink == 1)
+ log_thread_stop();
+ exit(1);
+ }
running_state = DAEMON_START;
@@ -1905,10 +1911,6 @@ child (void * param)
}
pthread_attr_destroy(&misc_attr);
- /* Startup complete, create logfile */
- pid_rc = pidfile_create(DEFAULT_PIDFILE, daemon_pid);
- /* Ignore errors, we can live without */
-
running_state = DAEMON_RUNNING;
#ifdef USE_SYSTEMD
sd_notify(0, "READY=1\nSTATUS=running");
@@ -1959,10 +1961,8 @@ child (void * param)
dm_lib_exit();
/* We're done here */
- if (!pid_rc) {
- condlog(3, "unlink pidfile");
- unlink(DEFAULT_PIDFILE);
- }
+ condlog(3, "unlink pidfile");
+ unlink(DEFAULT_PIDFILE);
condlog(2, "--------shut down-------");
--
1.8.3.1
next prev parent reply other threads:[~2016-03-29 3:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-29 3:12 [PATCH 00/17] Multipath patch sync Benjamin Marzinski
2016-03-29 3:12 ` [PATCH 01/17] multipathd: use /run instead of /var/run Benjamin Marzinski
2016-03-29 13:57 ` John Stoffel
2016-03-30 0:41 ` Benjamin Marzinski
2016-03-30 16:06 ` John Stoffel
2016-03-29 3:12 ` [PATCH 02/17] retrigger uevents to try and get the uid through udev Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 03/17] Fix issues with user_friendly_names initramfs bindings Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 04/17] Add libmpathcmd library and use it internally Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 05/17] libmultipath: add ignore_new_boot_devs option Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 06/17] libmultipath: fix PAD and PRINT macros Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 07/17] libmultipath: Cut down on alua prioritizer ioctls Benjamin Marzinski
2016-03-29 3:13 ` Benjamin Marzinski [this message]
2016-03-29 3:13 ` [PATCH 09/17] libmultipath: check correct function for define Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 10/17] multipathd: delay reloads during creation Benjamin Marzinski
2016-03-29 14:02 ` John Stoffel
2016-03-30 0:57 ` Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 11/17] multipath: Fix minor text issues Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 12/17] kpartx: verify partition devices Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 13/17] multipath: add exclusive_pref_bit for alua prio Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 14/17] multipathd: print "fail" when remove fails Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 15/17] multipath: check partitions unused before removing Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 16/17] multipathd.service: remove blk-availability Requires Benjamin Marzinski
2016-03-29 3:13 ` [PATCH 17/17] multipathd: use 64-bit int for command key Benjamin Marzinski
2016-04-07 2:10 ` multipathd: segfault in multipathd cli_add_map() Zhangguanghui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459221194-23222-9-git-send-email-bmarzins@redhat.com \
--to=bmarzins@redhat.com \
--cc=christophe.varoqui@gmail.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).