|
|
4728c8 |
---
|
|
|
4728c8 |
libmultipath/file.c | 4 +-
|
|
|
4728c8 |
libmultipath/lock.c | 9 ----
|
|
|
4728c8 |
libmultipath/lock.h | 1
|
|
|
4728c8 |
libmultipath/log_pthread.c | 22 -----------
|
|
|
4728c8 |
libmultipath/waiter.c | 2 -
|
|
|
4728c8 |
multipathd/cli_handlers.c | 4 +-
|
|
|
4728c8 |
multipathd/main.c | 90 ++++++++++++++++++++-------------------------
|
|
|
4728c8 |
multipathd/main.h | 3 +
|
|
|
4728c8 |
multipathd/uxlsnr.c | 21 +++++++---
|
|
|
4728c8 |
multipathd/uxlsnr.h | 3 +
|
|
|
4728c8 |
10 files changed, 65 insertions(+), 94 deletions(-)
|
|
|
4728c8 |
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/file.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/file.c
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/file.c
|
|
|
4728c8 |
@@ -98,7 +98,7 @@ lock_file(int fd, char *file_name)
|
|
|
4728c8 |
sigaddset(&set, SIGALRM);
|
|
|
4728c8 |
|
|
|
4728c8 |
sigaction(SIGALRM, &act, &oldact);
|
|
|
4728c8 |
- sigprocmask(SIG_UNBLOCK, &set, &oldset);
|
|
|
4728c8 |
+ pthread_sigmask(SIG_UNBLOCK, &set, &oldset);
|
|
|
4728c8 |
|
|
|
4728c8 |
alarm(FILE_TIMEOUT);
|
|
|
4728c8 |
err = fcntl(fd, F_SETLKW, &lock);
|
|
|
4728c8 |
@@ -112,7 +112,7 @@ lock_file(int fd, char *file_name)
|
|
|
4728c8 |
condlog(0, "%s is locked. Giving up.", file_name);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
- sigprocmask(SIG_SETMASK, &oldset, NULL);
|
|
|
4728c8 |
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
|
|
4728c8 |
sigaction(SIGALRM, &oldact, NULL);
|
|
|
4728c8 |
return err;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/lock.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/lock.c
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/lock.c
|
|
|
4728c8 |
@@ -1,16 +1,7 @@
|
|
|
4728c8 |
#include <pthread.h>
|
|
|
4728c8 |
-#include <signal.h>
|
|
|
4728c8 |
#include "lock.h"
|
|
|
4728c8 |
#include <stdio.h>
|
|
|
4728c8 |
|
|
|
4728c8 |
-void block_signal (int signum, sigset_t *old)
|
|
|
4728c8 |
-{
|
|
|
4728c8 |
- sigset_t set;
|
|
|
4728c8 |
- sigemptyset(&set);
|
|
|
4728c8 |
- sigaddset(&set, signum);
|
|
|
4728c8 |
- pthread_sigmask(SIG_BLOCK, &set, old);
|
|
|
4728c8 |
-}
|
|
|
4728c8 |
-
|
|
|
4728c8 |
void cleanup_lock (void * data)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
unlock ((*(struct mutex_lock *)data));
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/lock.h
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/lock.h
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/lock.h
|
|
|
4728c8 |
@@ -29,6 +29,5 @@ struct mutex_lock {
|
|
|
4728c8 |
#endif
|
|
|
4728c8 |
|
|
|
4728c8 |
void cleanup_lock (void * data);
|
|
|
4728c8 |
-void block_signal(int signum, sigset_t *old);
|
|
|
4728c8 |
|
|
|
4728c8 |
#endif /* _LOCK_H */
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/log_pthread.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/log_pthread.c
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/log_pthread.c
|
|
|
4728c8 |
@@ -22,26 +22,13 @@ pthread_cond_t logev_cond;
|
|
|
4728c8 |
|
|
|
4728c8 |
int logq_running;
|
|
|
4728c8 |
|
|
|
4728c8 |
-static void
|
|
|
4728c8 |
-sigusr1 (int sig)
|
|
|
4728c8 |
-{
|
|
|
4728c8 |
- pthread_mutex_lock(&logq_lock);
|
|
|
4728c8 |
- log_reset("multipathd");
|
|
|
4728c8 |
- pthread_mutex_unlock(&logq_lock);
|
|
|
4728c8 |
-}
|
|
|
4728c8 |
-
|
|
|
4728c8 |
void log_safe (int prio, const char * fmt, va_list ap)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- sigset_t old;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
if (log_thr == (pthread_t)0) {
|
|
|
4728c8 |
syslog(prio, fmt, ap);
|
|
|
4728c8 |
return;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
- block_signal(SIGUSR1, &old;;
|
|
|
4728c8 |
- block_signal(SIGHUP, NULL);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
pthread_mutex_lock(&logq_lock);
|
|
|
4728c8 |
log_enqueue(prio, fmt, ap);
|
|
|
4728c8 |
pthread_mutex_unlock(&logq_lock);
|
|
|
4728c8 |
@@ -49,8 +36,6 @@ void log_safe (int prio, const char * fm
|
|
|
4728c8 |
pthread_mutex_lock(&logev_lock);
|
|
|
4728c8 |
pthread_cond_signal(&logev_cond);
|
|
|
4728c8 |
pthread_mutex_unlock(&logev_lock);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- pthread_sigmask(SIG_SETMASK, &old, NULL);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
void log_thread_flush (void)
|
|
|
4728c8 |
@@ -81,15 +66,8 @@ static void flush_logqueue (void)
|
|
|
4728c8 |
|
|
|
4728c8 |
static void * log_thread (void * et)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- struct sigaction sig;
|
|
|
4728c8 |
int running;
|
|
|
4728c8 |
|
|
|
4728c8 |
- sig.sa_handler = sigusr1;
|
|
|
4728c8 |
- sigemptyset(&sig.sa_mask);
|
|
|
4728c8 |
- sig.sa_flags = 0;
|
|
|
4728c8 |
- if (sigaction(SIGUSR1, &sig, NULL) < 0)
|
|
|
4728c8 |
- logdbg(stderr, "Cannot set signal handler");
|
|
|
4728c8 |
-
|
|
|
4728c8 |
pthread_mutex_lock(&logev_lock);
|
|
|
4728c8 |
logq_running = 1;
|
|
|
4728c8 |
pthread_mutex_unlock(&logev_lock);
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/waiter.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/waiter.c
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/waiter.c
|
|
|
4728c8 |
@@ -157,8 +157,6 @@ void *waitevent (void *et)
|
|
|
4728c8 |
waiter = (struct event_thread *)et;
|
|
|
4728c8 |
pthread_cleanup_push(free_waiter, et);
|
|
|
4728c8 |
|
|
|
4728c8 |
- block_signal(SIGUSR1, NULL);
|
|
|
4728c8 |
- block_signal(SIGHUP, NULL);
|
|
|
4728c8 |
while (1) {
|
|
|
4728c8 |
r = waiteventloop(waiter);
|
|
|
4728c8 |
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/cli_handlers.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/cli_handlers.c
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/cli_handlers.c
|
|
|
4728c8 |
@@ -939,8 +939,8 @@ int
|
|
|
4728c8 |
cli_shutdown (void * v, char ** reply, int * len, void * data)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
condlog(3, "shutdown (operator)");
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- return exit_daemon(0);
|
|
|
4728c8 |
+ exit_daemon();
|
|
|
4728c8 |
+ return 0;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
int
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/main.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/main.c
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/main.c
|
|
|
4728c8 |
@@ -17,6 +17,7 @@
|
|
|
4728c8 |
#include <limits.h>
|
|
|
4728c8 |
#include <linux/oom.h>
|
|
|
4728c8 |
#include <libudev.h>
|
|
|
4728c8 |
+#include <semaphore.h>
|
|
|
4728c8 |
#include <mpath_persist.h>
|
|
|
4728c8 |
|
|
|
4728c8 |
/*
|
|
|
4728c8 |
@@ -52,6 +53,7 @@
|
|
|
4728c8 |
#include <wwids.h>
|
|
|
4728c8 |
#include <pgpolicies.h>
|
|
|
4728c8 |
#include <uevent.h>
|
|
|
4728c8 |
+#include <log.h>
|
|
|
4728c8 |
|
|
|
4728c8 |
#include "main.h"
|
|
|
4728c8 |
#include "pidfile.h"
|
|
|
4728c8 |
@@ -81,13 +83,11 @@ struct mpath_event_param
|
|
|
4728c8 |
|
|
|
4728c8 |
unsigned int mpath_mx_alloc_len;
|
|
|
4728c8 |
|
|
|
4728c8 |
-pthread_cond_t exit_cond = PTHREAD_COND_INITIALIZER;
|
|
|
4728c8 |
-pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
int logsink;
|
|
|
4728c8 |
enum daemon_status running_state;
|
|
|
4728c8 |
pid_t daemon_pid;
|
|
|
4728c8 |
|
|
|
4728c8 |
+static sem_t exit_sem;
|
|
|
4728c8 |
/*
|
|
|
4728c8 |
* global copy of vecs for use in sig handlers
|
|
|
4728c8 |
*/
|
|
|
4728c8 |
@@ -838,9 +838,6 @@ out:
|
|
|
4728c8 |
static void *
|
|
|
4728c8 |
ueventloop (void * ap)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- block_signal(SIGUSR1, NULL);
|
|
|
4728c8 |
- block_signal(SIGHUP, NULL);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
if (uevent_listen())
|
|
|
4728c8 |
condlog(0, "error starting uevent listener");
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -850,9 +847,6 @@ ueventloop (void * ap)
|
|
|
4728c8 |
static void *
|
|
|
4728c8 |
uevqloop (void * ap)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- block_signal(SIGUSR1, NULL);
|
|
|
4728c8 |
- block_signal(SIGHUP, NULL);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
if (uevent_dispatch(&uev_trigger, ap))
|
|
|
4728c8 |
condlog(0, "error starting uevent dispatcher");
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -861,9 +855,6 @@ uevqloop (void * ap)
|
|
|
4728c8 |
static void *
|
|
|
4728c8 |
uxlsnrloop (void * ap)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- block_signal(SIGUSR1, NULL);
|
|
|
4728c8 |
- block_signal(SIGHUP, NULL);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
if (cli_init())
|
|
|
4728c8 |
return NULL;
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -913,18 +904,10 @@ uxlsnrloop (void * ap)
|
|
|
4728c8 |
return NULL;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
-int
|
|
|
4728c8 |
-exit_daemon (int status)
|
|
|
4728c8 |
+void
|
|
|
4728c8 |
+exit_daemon (void)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- if (status != 0)
|
|
|
4728c8 |
- fprintf(stderr, "bad exit status. see daemon.log\n");
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (running_state != DAEMON_SHUTDOWN) {
|
|
|
4728c8 |
- pthread_mutex_lock(&exit_mutex);
|
|
|
4728c8 |
- pthread_cond_signal(&exit_cond);
|
|
|
4728c8 |
- pthread_mutex_unlock(&exit_mutex);
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
- return status;
|
|
|
4728c8 |
+ sem_post(&exit_sem);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
const char *
|
|
|
4728c8 |
@@ -1287,7 +1270,6 @@ checkerloop (void *ap)
|
|
|
4728c8 |
struct path *pp;
|
|
|
4728c8 |
int count = 0;
|
|
|
4728c8 |
unsigned int i;
|
|
|
4728c8 |
- sigset_t old;
|
|
|
4728c8 |
|
|
|
4728c8 |
mlockall(MCL_CURRENT | MCL_FUTURE);
|
|
|
4728c8 |
vecs = (struct vectors *)ap;
|
|
|
4728c8 |
@@ -1301,7 +1283,6 @@ checkerloop (void *ap)
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
while (1) {
|
|
|
4728c8 |
- block_signal(SIGHUP, &old;;
|
|
|
4728c8 |
pthread_cleanup_push(cleanup_lock, &vecs->lock);
|
|
|
4728c8 |
lock(vecs->lock);
|
|
|
4728c8 |
pthread_testcancel();
|
|
|
4728c8 |
@@ -1325,7 +1306,6 @@ checkerloop (void *ap)
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
lock_cleanup_pop(vecs->lock);
|
|
|
4728c8 |
- pthread_sigmask(SIG_SETMASK, &old, NULL);
|
|
|
4728c8 |
sleep(1);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
return NULL;
|
|
|
4728c8 |
@@ -1485,36 +1465,56 @@ signal_set(int signo, void (*func) (int)
|
|
|
4728c8 |
return (osig.sa_handler);
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
+void
|
|
|
4728c8 |
+handle_signals(void)
|
|
|
4728c8 |
+{
|
|
|
4728c8 |
+ if (reconfig_sig && running_state == DAEMON_RUNNING) {
|
|
|
4728c8 |
+ condlog(2, "reconfigure (signal)");
|
|
|
4728c8 |
+ pthread_cleanup_push(cleanup_lock,
|
|
|
4728c8 |
+ &gvecs->lock);
|
|
|
4728c8 |
+ lock(gvecs->lock);
|
|
|
4728c8 |
+ pthread_testcancel();
|
|
|
4728c8 |
+ reconfigure(gvecs);
|
|
|
4728c8 |
+ lock_cleanup_pop(gvecs->lock);
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
+ if (log_reset_sig) {
|
|
|
4728c8 |
+ condlog(2, "reset log (signal)");
|
|
|
4728c8 |
+ pthread_mutex_lock(&logq_lock);
|
|
|
4728c8 |
+ log_reset("multipathd");
|
|
|
4728c8 |
+ pthread_mutex_unlock(&logq_lock);
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
+ reconfig_sig = 0;
|
|
|
4728c8 |
+ log_reset_sig = 0;
|
|
|
4728c8 |
+}
|
|
|
4728c8 |
+
|
|
|
4728c8 |
static void
|
|
|
4728c8 |
sighup (int sig)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- condlog(2, "reconfigure (SIGHUP)");
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- if (running_state != DAEMON_RUNNING)
|
|
|
4728c8 |
- return;
|
|
|
4728c8 |
-
|
|
|
4728c8 |
- reconfigure(gvecs);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
-#ifdef _DEBUG_
|
|
|
4728c8 |
- dbg_free_final(NULL);
|
|
|
4728c8 |
-#endif
|
|
|
4728c8 |
+ reconfig_sig = 1;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
static void
|
|
|
4728c8 |
sigend (int sig)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- exit_daemon(0);
|
|
|
4728c8 |
+ exit_daemon();
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
static void
|
|
|
4728c8 |
sigusr1 (int sig)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- condlog(3, "SIGUSR1 received");
|
|
|
4728c8 |
+ log_reset_sig = 1;
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
static void
|
|
|
4728c8 |
signal_init(void)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
+ sigset_t set;
|
|
|
4728c8 |
+
|
|
|
4728c8 |
+ sigemptyset(&set);
|
|
|
4728c8 |
+ sigaddset(&set, SIGHUP);
|
|
|
4728c8 |
+ sigaddset(&set, SIGUSR1);
|
|
|
4728c8 |
+ pthread_sigmask(SIG_BLOCK, &set, NULL);
|
|
|
4728c8 |
+
|
|
|
4728c8 |
signal_set(SIGHUP, sighup);
|
|
|
4728c8 |
signal_set(SIGUSR1, sigusr1);
|
|
|
4728c8 |
signal_set(SIGINT, sigend);
|
|
|
4728c8 |
@@ -1587,10 +1587,11 @@ child (void * param)
|
|
|
4728c8 |
struct vectors * vecs;
|
|
|
4728c8 |
struct multipath * mpp;
|
|
|
4728c8 |
int i;
|
|
|
4728c8 |
- sigset_t set;
|
|
|
4728c8 |
int rc, pid_rc;
|
|
|
4728c8 |
|
|
|
4728c8 |
mlockall(MCL_CURRENT | MCL_FUTURE);
|
|
|
4728c8 |
+ sem_init(&exit_sem, 0, 0);
|
|
|
4728c8 |
+ signal_init();
|
|
|
4728c8 |
|
|
|
4728c8 |
setup_thread_attr(&misc_attr, 64 * 1024, 1);
|
|
|
4728c8 |
setup_thread_attr(&waiter_attr, 32 * 1024, 1);
|
|
|
4728c8 |
@@ -1650,7 +1651,6 @@ child (void * param)
|
|
|
4728c8 |
if (!vecs)
|
|
|
4728c8 |
exit(1);
|
|
|
4728c8 |
|
|
|
4728c8 |
- signal_init();
|
|
|
4728c8 |
setscheduler();
|
|
|
4728c8 |
set_oom_adj();
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -1693,25 +1693,17 @@ child (void * param)
|
|
|
4728c8 |
}
|
|
|
4728c8 |
pthread_attr_destroy(&misc_attr);
|
|
|
4728c8 |
|
|
|
4728c8 |
- pthread_mutex_lock(&exit_mutex);
|
|
|
4728c8 |
/* Startup complete, create logfile */
|
|
|
4728c8 |
pid_rc = pidfile_create(DEFAULT_PIDFILE, daemon_pid);
|
|
|
4728c8 |
/* Ignore errors, we can live without */
|
|
|
4728c8 |
|
|
|
4728c8 |
running_state = DAEMON_RUNNING;
|
|
|
4728c8 |
- pthread_cond_wait(&exit_cond, &exit_mutex);
|
|
|
4728c8 |
- /* Need to block these to avoid deadlocking */
|
|
|
4728c8 |
- sigemptyset(&set);
|
|
|
4728c8 |
- sigaddset(&set, SIGTERM);
|
|
|
4728c8 |
- sigaddset(&set, SIGINT);
|
|
|
4728c8 |
- pthread_sigmask(SIG_BLOCK, &set, NULL);
|
|
|
4728c8 |
|
|
|
4728c8 |
/*
|
|
|
4728c8 |
* exit path
|
|
|
4728c8 |
*/
|
|
|
4728c8 |
+ while(sem_wait(&exit_sem) != 0); /* Do nothing */
|
|
|
4728c8 |
running_state = DAEMON_SHUTDOWN;
|
|
|
4728c8 |
- pthread_sigmask(SIG_UNBLOCK, &set, NULL);
|
|
|
4728c8 |
- block_signal(SIGHUP, NULL);
|
|
|
4728c8 |
lock(vecs->lock);
|
|
|
4728c8 |
if (conf->queue_without_daemon == QUE_NO_DAEMON_OFF)
|
|
|
4728c8 |
vector_foreach_slot(vecs->mpvec, mpp, i)
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/main.h
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/main.h
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/main.h
|
|
|
4728c8 |
@@ -16,7 +16,7 @@ struct prin_resp;
|
|
|
4728c8 |
|
|
|
4728c8 |
extern pid_t daemon_pid;
|
|
|
4728c8 |
|
|
|
4728c8 |
-int exit_daemon(int);
|
|
|
4728c8 |
+void exit_daemon(void);
|
|
|
4728c8 |
const char * daemon_status(void);
|
|
|
4728c8 |
int reconfigure (struct vectors *);
|
|
|
4728c8 |
int ev_add_path (struct path *, struct vectors *);
|
|
|
4728c8 |
@@ -35,5 +35,6 @@ int mpath_pr_event_handle(struct path *p
|
|
|
4728c8 |
void * mpath_pr_event_handler_fn (void * );
|
|
|
4728c8 |
int update_map_pr(struct multipath *mpp);
|
|
|
4728c8 |
void * mpath_pr_event_handler_fn (void * pathp );
|
|
|
4728c8 |
+void handle_signals(void);
|
|
|
4728c8 |
|
|
|
4728c8 |
#endif /* MAIN_H */
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/uxlsnr.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/uxlsnr.c
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/uxlsnr.c
|
|
|
4728c8 |
@@ -8,6 +8,7 @@
|
|
|
4728c8 |
/*
|
|
|
4728c8 |
* A simple domain socket listener
|
|
|
4728c8 |
*/
|
|
|
4728c8 |
+#define _GNU_SOURCE
|
|
|
4728c8 |
#include <stdio.h>
|
|
|
4728c8 |
#include <stdlib.h>
|
|
|
4728c8 |
#include <unistd.h>
|
|
|
4728c8 |
@@ -19,20 +20,21 @@
|
|
|
4728c8 |
#include <sys/socket.h>
|
|
|
4728c8 |
#include <sys/un.h>
|
|
|
4728c8 |
#include <sys/poll.h>
|
|
|
4728c8 |
-
|
|
|
4728c8 |
+#include <signal.h>
|
|
|
4728c8 |
#include <checkers.h>
|
|
|
4728c8 |
-
|
|
|
4728c8 |
#include <memory.h>
|
|
|
4728c8 |
#include <debug.h>
|
|
|
4728c8 |
#include <vector.h>
|
|
|
4728c8 |
#include <structs.h>
|
|
|
4728c8 |
+#include <structs_vec.h>
|
|
|
4728c8 |
#include <uxsock.h>
|
|
|
4728c8 |
#include <defaults.h>
|
|
|
4728c8 |
|
|
|
4728c8 |
+#include "main.h"
|
|
|
4728c8 |
#include "cli.h"
|
|
|
4728c8 |
#include "uxlsnr.h"
|
|
|
4728c8 |
|
|
|
4728c8 |
-#define SLEEP_TIME 5000
|
|
|
4728c8 |
+struct timespec sleep_time = {5, 0};
|
|
|
4728c8 |
|
|
|
4728c8 |
struct client {
|
|
|
4728c8 |
int fd;
|
|
|
4728c8 |
@@ -42,6 +44,8 @@ struct client {
|
|
|
4728c8 |
static struct client *clients;
|
|
|
4728c8 |
static unsigned num_clients;
|
|
|
4728c8 |
struct pollfd *polls;
|
|
|
4728c8 |
+volatile sig_atomic_t reconfig_sig = 0;
|
|
|
4728c8 |
+volatile sig_atomic_t log_reset_sig = 0;
|
|
|
4728c8 |
|
|
|
4728c8 |
/*
|
|
|
4728c8 |
* handle a new client joining
|
|
|
4728c8 |
@@ -104,6 +108,7 @@ void * uxsock_listen(int (*uxsock_trigge
|
|
|
4728c8 |
int rlen;
|
|
|
4728c8 |
char *inbuf;
|
|
|
4728c8 |
char *reply;
|
|
|
4728c8 |
+ sigset_t mask;
|
|
|
4728c8 |
|
|
|
4728c8 |
ux_sock = ux_socket_listen(DEFAULT_SOCKET);
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -115,7 +120,9 @@ void * uxsock_listen(int (*uxsock_trigge
|
|
|
4728c8 |
pthread_cleanup_push(uxsock_cleanup, NULL);
|
|
|
4728c8 |
|
|
|
4728c8 |
polls = (struct pollfd *)MALLOC(0);
|
|
|
4728c8 |
-
|
|
|
4728c8 |
+ pthread_sigmask(SIG_SETMASK, NULL, &mask);
|
|
|
4728c8 |
+ sigdelset(&mask, SIGHUP);
|
|
|
4728c8 |
+ sigdelset(&mask, SIGUSR1);
|
|
|
4728c8 |
while (1) {
|
|
|
4728c8 |
struct client *c;
|
|
|
4728c8 |
int i, poll_count;
|
|
|
4728c8 |
@@ -132,11 +139,13 @@ void * uxsock_listen(int (*uxsock_trigge
|
|
|
4728c8 |
}
|
|
|
4728c8 |
|
|
|
4728c8 |
/* most of our life is spent in this call */
|
|
|
4728c8 |
- poll_count = poll(polls, i, SLEEP_TIME);
|
|
|
4728c8 |
+ poll_count = ppoll(polls, i, &sleep_time, &mask);
|
|
|
4728c8 |
|
|
|
4728c8 |
if (poll_count == -1) {
|
|
|
4728c8 |
- if (errno == EINTR)
|
|
|
4728c8 |
+ if (errno == EINTR) {
|
|
|
4728c8 |
+ handle_signals();
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
|
|
|
4728c8 |
/* something went badly wrong! */
|
|
|
4728c8 |
condlog(0, "poll");
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/uxlsnr.h
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/uxlsnr.h
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/uxlsnr.h
|
|
|
4728c8 |
@@ -4,5 +4,8 @@
|
|
|
4728c8 |
void * uxsock_listen(int (*uxsock_trigger)
|
|
|
4728c8 |
(char *, char **, int *, void *),
|
|
|
4728c8 |
void * trigger_data);
|
|
|
4728c8 |
+
|
|
|
4728c8 |
+extern volatile sig_atomic_t reconfig_sig;
|
|
|
4728c8 |
+extern volatile sig_atomic_t log_reset_sig;
|
|
|
4728c8 |
#endif
|
|
|
4728c8 |
|