File multipath-tools-use-pthread_sigmask-in-alias of Package multipath-tools
commit 928c0261d52bd527c17ae2a67a9034fba66c09b2
Author: Hannes Reinecke <hare@suse.de>
Date: Fri Mar 20 12:40:38 2009 +0100
Use pthread_sigmask in alias.c when in daemon mode
sigprocmask is undefined when running multithreaded.
So we should rather use pthread_sigmask() here when
we're being called from the daemon.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/libmultipath/alias.c b/libmultipath/alias.c
index 8473187..567f048 100644
--- a/libmultipath/alias.c
+++ b/libmultipath/alias.c
@@ -16,7 +16,8 @@
#include "debug.h"
#include "uxsock.h"
#include "alias.h"
-
+#include "vector.h"
+#include "config.h"
/*
* significant parts of this file were taken from iscsi-bindings.c of the
@@ -98,7 +99,10 @@ lock_bindings_file(int fd)
sigaddset(&set, SIGALRM);
sigaction(SIGALRM, &act, &oldact);
- sigprocmask(SIG_UNBLOCK, &set, &oldset);
+ if (conf->daemon)
+ pthread_sigmask(SIG_UNBLOCK, &set, &oldset);
+ else
+ sigprocmask(SIG_UNBLOCK, &set, &oldset);
alarm(BINDINGS_FILE_TIMEOUT);
err = fcntl(fd, F_SETLKW, &lock);
@@ -112,7 +116,10 @@ lock_bindings_file(int fd)
condlog(0, "Bindings file is locked. Giving up.");
}
- sigprocmask(SIG_SETMASK, &oldset, NULL);
+ if (conf->daemon)
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+ else
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
sigaction(SIGALRM, &oldact, NULL);
return err;
@@ -352,7 +359,7 @@ allocate_binding(int fd, char *wwid, int id)
}
char *
-get_user_friendly_alias(char *wwid, char *file)
+get_user_friendly_alias(char *wwid)
{
char *alias;
int fd, scan_fd, id;
@@ -364,7 +371,7 @@ get_user_friendly_alias(char *wwid, char *file)
return NULL;
}
- fd = open_bindings_file(file, &can_write);
+ fd = open_bindings_file(conf->bindings_file, &can_write);
if (fd < 0)
return NULL;
@@ -403,7 +410,7 @@ get_user_friendly_alias(char *wwid, char *file)
}
char *
-get_user_friendly_wwid(char *alias, char *file)
+get_user_friendly_wwid(char *alias)
{
char *wwid;
int fd, scan_fd, id, unused;
@@ -414,7 +421,7 @@ get_user_friendly_wwid(char *alias, char *file)
return NULL;
}
- fd = open_bindings_file(file, &unused);
+ fd = open_bindings_file(conf->bindings_file, &unused);
if (fd < 0)
return NULL;
diff --git a/libmultipath/alias.h b/libmultipath/alias.h
index fe1191b..af7d0e3 100644
--- a/libmultipath/alias.h
+++ b/libmultipath/alias.h
@@ -8,5 +8,5 @@
"# alias wwid\n" \
"#\n"
-char *get_user_friendly_alias(char *wwid, char *file);
-char *get_user_friendly_wwid(char *alias, char *file);
+char *get_user_friendly_alias(char *wwid);
+char *get_user_friendly_wwid(char *alias);
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index cf8296e..f7f2f2b 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -652,8 +652,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec)
/*
* may be a binding
*/
- refwwid = get_user_friendly_wwid(dev,
- conf->bindings_file);
+ refwwid = get_user_friendly_wwid(dev);
if (refwwid)
return refwwid;
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index 72c0fa6..98ea334 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -163,8 +163,7 @@ select_alias (struct multipath * mp)
else {
mp->alias = NULL;
if (conf->user_friendly_names)
- mp->alias = get_user_friendly_alias(mp->wwid,
- conf->bindings_file);
+ mp->alias = get_user_friendly_alias(mp->wwid);
if (mp->alias == NULL){
char *alias;
if ((alias = MALLOC(WWID_SIZE)) != NULL){