|
|
ad0d7c |
From d3292ee776448de67241bf7efc8f9bb23f166752 Mon Sep 17 00:00:00 2001
|
|
|
ad0d7c |
From: Quentin Armitage <quentin@armitage.org.uk>
|
|
|
ad0d7c |
Date: Fri, 2 Feb 2018 10:12:06 +0000
|
|
|
ad0d7c |
Subject: [PATCH 1/8] Add child_wait_time to allow longer shutdown time of
|
|
|
ad0d7c |
child processes
|
|
|
ad0d7c |
|
|
|
ad0d7c |
With very large configurations it can be necessary to allow longer than
|
|
|
ad0d7c |
the default 5 seconds for child processes to cleanup and terminate.
|
|
|
ad0d7c |
|
|
|
ad0d7c |
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
|
|
|
ad0d7c |
---
|
|
|
ad0d7c |
doc/keepalived.conf.SYNOPSIS | 5 ++++-
|
|
|
ad0d7c |
doc/man/man5/keepalived.conf.5 | 3 +++
|
|
|
ad0d7c |
keepalived/core/global_parser.c | 19 +++++++++++++++++++
|
|
|
ad0d7c |
keepalived/core/main.c | 12 +++++++-----
|
|
|
ad0d7c |
keepalived/include/main.h | 3 +++
|
|
|
ad0d7c |
lib/parser.c | 2 ++
|
|
|
ad0d7c |
6 files changed, 38 insertions(+), 6 deletions(-)
|
|
|
ad0d7c |
|
|
|
ad0d7c |
diff --git a/doc/keepalived.conf.SYNOPSIS b/doc/keepalived.conf.SYNOPSIS
|
|
|
ad0d7c |
index 90eb83d4..3d042b1c 100644
|
|
|
ad0d7c |
--- a/doc/keepalived.conf.SYNOPSIS
|
|
|
ad0d7c |
+++ b/doc/keepalived.conf.SYNOPSIS
|
|
|
ad0d7c |
@@ -176,7 +176,10 @@ use_pid_dir # Create pid files in /var/run/keepalived
|
|
|
ad0d7c |
|
|
|
ad0d7c |
linkbeat_use_polling # Use media link failure detection polling fashion
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- 1.2. Static addresses
|
|
|
ad0d7c |
+child_wait_time SECS # Time for main process to allow for child processes to exit on termination
|
|
|
ad0d7c |
+ # in seconds (default 5). This can be needed for very large configurations.
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ 1.2. Static addresses
|
|
|
ad0d7c |
|
|
|
ad0d7c |
The configuration block looks like :
|
|
|
ad0d7c |
|
|
|
ad0d7c |
diff --git a/doc/man/man5/keepalived.conf.5 b/doc/man/man5/keepalived.conf.5
|
|
|
ad0d7c |
index 1dabdec7..d0d04727 100644
|
|
|
ad0d7c |
--- a/doc/man/man5/keepalived.conf.5
|
|
|
ad0d7c |
+++ b/doc/man/man5/keepalived.conf.5
|
|
|
ad0d7c |
@@ -219,6 +219,9 @@ and
|
|
|
ad0d7c |
|
|
|
ad0d7c |
linkbeat_use_polling # Poll to detect media link failure otherwise attempt to use ETHTOOL or MII interface
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+ child_wait_time SECS # Time for main process to allow for child processes to exit on termination
|
|
|
ad0d7c |
+ # in seconds (default 5). This can be needed for very large configurations.
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
.SH Static routes/addresses/rules
|
|
|
ad0d7c |
.PP
|
|
|
ad0d7c |
Keepalived can configure static addresses, routes, and rules. These addresses are
|
|
|
ad0d7c |
diff --git a/keepalived/core/global_parser.c b/keepalived/core/global_parser.c
|
|
|
ad0d7c |
index a59fbc0b..e8ed6333 100644
|
|
|
ad0d7c |
--- a/keepalived/core/global_parser.c
|
|
|
ad0d7c |
+++ b/keepalived/core/global_parser.c
|
|
|
ad0d7c |
@@ -719,6 +719,24 @@ script_security_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
global_data->script_security = true;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+static void
|
|
|
ad0d7c |
+child_wait_handler(vector_t *strvec)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ char *endptr;
|
|
|
ad0d7c |
+ unsigned long secs;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (!strvec)
|
|
|
ad0d7c |
+ return;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ secs = strtoul(strvec_slot(strvec,1), &endptr, 10);
|
|
|
ad0d7c |
+ if (*endptr) {
|
|
|
ad0d7c |
+ log_message(LOG_INFO, "Invalid child_wait_time %s", FMT_STR_VSLOT(strvec, 1));
|
|
|
ad0d7c |
+ return;
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ child_wait_time = secs;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
void
|
|
|
ad0d7c |
init_global_keywords(bool global_active)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -730,6 +748,7 @@ init_global_keywords(bool global_active)
|
|
|
ad0d7c |
#endif
|
|
|
ad0d7c |
install_keyword_root("use_pid_dir", &use_pid_dir_handler, !global_active);
|
|
|
ad0d7c |
install_keyword_root("instance", &instance_handler, !global_active);
|
|
|
ad0d7c |
+ install_keyword_root("child_wait_time", &child_wait_handler, !global_active);
|
|
|
ad0d7c |
install_keyword_root("global_defs", NULL, global_active);
|
|
|
ad0d7c |
install_keyword("router_id", &routerid_handler);
|
|
|
ad0d7c |
install_keyword("notification_email_from", &emailfrom_handler);
|
|
|
ad0d7c |
diff --git a/keepalived/core/main.c b/keepalived/core/main.c
|
|
|
ad0d7c |
index 95bb76a9..51f83a07 100644
|
|
|
ad0d7c |
--- a/keepalived/core/main.c
|
|
|
ad0d7c |
+++ b/keepalived/core/main.c
|
|
|
ad0d7c |
@@ -93,6 +93,8 @@ bool namespace_with_ipsets; /* Override for using namespaces and ipsets with
|
|
|
ad0d7c |
static char *override_namespace; /* If namespace specified on command line */
|
|
|
ad0d7c |
#endif
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+unsigned child_wait_time = CHILD_WAIT_SECS; /* Time to wait for children to exit */
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
/* Log facility table */
|
|
|
ad0d7c |
static struct {
|
|
|
ad0d7c |
int facility;
|
|
|
ad0d7c |
@@ -359,7 +361,7 @@ sigend(__attribute__((unused)) void *v, __attribute__((unused)) int sig)
|
|
|
ad0d7c |
int wait_count = 0;
|
|
|
ad0d7c |
sigset_t old_set, child_wait;
|
|
|
ad0d7c |
struct timespec timeout = {
|
|
|
ad0d7c |
- .tv_sec = CHILD_WAIT_SECS,
|
|
|
ad0d7c |
+ .tv_sec = child_wait_time,
|
|
|
ad0d7c |
.tv_nsec = 0
|
|
|
ad0d7c |
};
|
|
|
ad0d7c |
struct timeval start_time, now;
|
|
|
ad0d7c |
@@ -416,17 +418,17 @@ sigend(__attribute__((unused)) void *v, __attribute__((unused)) int sig)
|
|
|
ad0d7c |
gettimeofday(&now, NULL);
|
|
|
ad0d7c |
if (now.tv_usec < start_time.tv_usec) {
|
|
|
ad0d7c |
timeout.tv_nsec = (start_time.tv_usec - now.tv_usec) * 1000;
|
|
|
ad0d7c |
- timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec);
|
|
|
ad0d7c |
+ timeout.tv_sec = child_wait_time - (now.tv_sec - start_time.tv_sec);
|
|
|
ad0d7c |
} else if (now.tv_usec == start_time.tv_usec) {
|
|
|
ad0d7c |
timeout.tv_nsec = 0;
|
|
|
ad0d7c |
- timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec);
|
|
|
ad0d7c |
+ timeout.tv_sec = child_wait_time - (now.tv_sec - start_time.tv_sec);
|
|
|
ad0d7c |
} else {
|
|
|
ad0d7c |
timeout.tv_nsec = (1000000L + start_time.tv_usec - now.tv_usec) * 1000;
|
|
|
ad0d7c |
- timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec + 1);
|
|
|
ad0d7c |
+ timeout.tv_sec = child_wait_time - (now.tv_sec - start_time.tv_sec + 1);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
timeout.tv_nsec = (start_time.tv_usec - now.tv_usec) * 1000;
|
|
|
ad0d7c |
- timeout.tv_sec = CHILD_WAIT_SECS - (now.tv_sec - start_time.tv_sec);
|
|
|
ad0d7c |
+ timeout.tv_sec = child_wait_time - (now.tv_sec - start_time.tv_sec);
|
|
|
ad0d7c |
if (timeout.tv_nsec < 0) {
|
|
|
ad0d7c |
timeout.tv_nsec += 1000000000L;
|
|
|
ad0d7c |
timeout.tv_sec--;
|
|
|
ad0d7c |
diff --git a/keepalived/include/main.h b/keepalived/include/main.h
|
|
|
ad0d7c |
index eebde77e..b03a7efd 100644
|
|
|
ad0d7c |
--- a/keepalived/include/main.h
|
|
|
ad0d7c |
+++ b/keepalived/include/main.h
|
|
|
ad0d7c |
@@ -82,4 +82,7 @@ extern void free_parent_mallocs_exit(void);
|
|
|
ad0d7c |
extern char *make_syslog_ident(const char*);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
extern int keepalived_main(int, char**); /* The "real" main function */
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+extern unsigned child_wait_time;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
#endif
|
|
|
ad0d7c |
diff --git a/lib/parser.c b/lib/parser.c
|
|
|
ad0d7c |
index a5c3465b..2e1beac8 100644
|
|
|
ad0d7c |
--- a/lib/parser.c
|
|
|
ad0d7c |
+++ b/lib/parser.c
|
|
|
ad0d7c |
@@ -120,6 +120,8 @@ install_sublevel_end(void)
|
|
|
ad0d7c |
void
|
|
|
ad0d7c |
install_keyword_root(const char *string, void (*handler) (vector_t *), bool active)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
+ /* If the root keyword is inactive, the handler will still be called,
|
|
|
ad0d7c |
+ * but with a NULL strvec */
|
|
|
ad0d7c |
keyword_alloc(keywords, string, handler, active);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
--
|
|
|
ad0d7c |
2.20.1
|
|
|
ad0d7c |
|