1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

Tidy clvmd's SIGHUP handler so it doesn't do all that work.

This commit is contained in:
Patrick Caulfield 2005-04-19 10:36:42 +00:00
parent 66278a80b1
commit 30bda7761e
4 changed files with 29 additions and 9 deletions

View File

@ -9,6 +9,7 @@ Version 2.01.10 -
Annotate, tidy and extend list.h. Annotate, tidy and extend list.h.
Alignment tidying. Alignment tidying.
Make clvmd work around some "bugs" in gulm's node state notifications. Make clvmd work around some "bugs" in gulm's node state notifications.
Tidy clvmd's SIGHUP handler
Version 2.01.09 - 4th April 2005 Version 2.01.09 - 4th April 2005
================================ ================================

View File

@ -40,6 +40,7 @@ struct cluster_ops {
void (*get_our_csid) (char *csid); void (*get_our_csid) (char *csid);
void (*add_up_node) (char *csid); void (*add_up_node) (char *csid);
void (*reread_config) (void);
void (*cluster_closedown) (void); void (*cluster_closedown) (void);
int (*sync_lock) (const char *resource, int mode, int flags, int *lockid); int (*sync_lock) (const char *resource, int mode, int flags, int *lockid);

View File

@ -136,12 +136,11 @@ static void badsig_handler(int sig)
exit(0); exit(0);
} }
static void sighup_handler(int sig) static void _reread_config(void)
{ {
DEBUGLOG("got SIGHUP\n"); /* Re-read CCS node list */
DEBUGLOG("Re-reading CCS config\n");
/* Re-read CCS node list */ get_all_cluster_nodes();
get_all_cluster_nodes();
} }
static int _init_cluster(void) static int _init_cluster(void)
@ -244,9 +243,6 @@ static int _init_cluster(void)
signal(SIGINT, badsig_handler); signal(SIGINT, badsig_handler);
signal(SIGTERM, badsig_handler); signal(SIGTERM, badsig_handler);
/* Re-read the node list on SIGHUP */
signal(SIGHUP, sighup_handler);
return 0; return 0;
} }
@ -986,6 +982,7 @@ static struct cluster_ops _cluster_gulm_ops = {
.is_quorate = _is_quorate, .is_quorate = _is_quorate,
.get_our_csid = _get_our_csid, .get_our_csid = _get_our_csid,
.add_up_node = gulm_add_up_node, .add_up_node = gulm_add_up_node,
.reread_config = _reread_config,
.cluster_closedown = _cluster_closedown, .cluster_closedown = _cluster_closedown,
.sync_lock = _sync_lock, .sync_lock = _sync_lock,
.sync_unlock = _sync_unlock, .sync_unlock = _sync_unlock,

View File

@ -90,6 +90,7 @@ static pthread_cond_t lvm_thread_cond;
static pthread_mutex_t lvm_start_mutex; static pthread_mutex_t lvm_start_mutex;
static struct list lvm_cmd_head; static struct list lvm_cmd_head;
static volatile sig_atomic_t quit = 0; static volatile sig_atomic_t quit = 0;
static volatile sig_atomic_t reread_config = 0;
static int child_pipe[2]; static int child_pipe[2];
/* Reasons the daemon failed initialisation */ /* Reasons the daemon failed initialisation */
@ -101,6 +102,7 @@ static int child_pipe[2];
/* Prototypes for code further down */ /* Prototypes for code further down */
static void sigusr2_handler(int sig); static void sigusr2_handler(int sig);
static void sighup_handler(int sig);
static void sigterm_handler(int sig); static void sigterm_handler(int sig);
static void send_local_reply(struct local_client *client, int status, static void send_local_reply(struct local_client *client, int status,
int clientid); int clientid);
@ -222,8 +224,10 @@ int main(int argc, char *argv[])
/* Set up signal handlers, USR1 is for cluster change notifications (in cman) /* Set up signal handlers, USR1 is for cluster change notifications (in cman)
USR2 causes child threads to exit. USR2 causes child threads to exit.
HUP causes gulm version to re-read nodes list from CCS.
PIPE should be ignored */ PIPE should be ignored */
signal(SIGUSR2, sigusr2_handler); signal(SIGUSR2, sigusr2_handler);
signal(SIGHUP, sighup_handler);
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
/* Block SIGUSR2 in the main process */ /* Block SIGUSR2 in the main process */
@ -514,7 +518,18 @@ static void main_loop(int local_sock, int cmd_timeout)
FD_SET(thisfd->fd, &in); FD_SET(thisfd->fd, &in);
} }
if ((select_status = select(FD_SETSIZE, &in, NULL, NULL, &tv)) > 0) { select_status = select(FD_SETSIZE, &in, NULL, NULL, &tv);
if (reread_config) {
int saved_errno = errno;
reread_config = 0;
if (clops->reread_config)
clops->reread_config();
errno = saved_errno;
}
if (select_status > 0) {
struct local_client *lastfd = NULL; struct local_client *lastfd = NULL;
char csid[MAX_CSID_LEN]; char csid[MAX_CSID_LEN];
char buf[max_cluster_message]; char buf[max_cluster_message];
@ -1820,6 +1835,12 @@ static void sigterm_handler(int sig)
return; return;
} }
static void sighup_handler(int sig)
{
DEBUGLOG("got SIGHUP\n");
reread_config = 1;
}
int sync_lock(const char *resource, int mode, int flags, int *lockid) int sync_lock(const char *resource, int mode, int flags, int *lockid)
{ {
return clops->sync_lock(resource, mode, flags, lockid); return clops->sync_lock(resource, mode, flags, lockid);