summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2019-07-03 11:09:52 +0200
committerMaria Matejka <mq@ucw.cz>2019-07-03 11:12:25 +0200
commiteac9250fd5b10809830361b94438339b3b31b270 (patch)
tree5c9ec2591f0baa462f5572f83e4c452c3a166c95 /conf
parent8816b6cdd98d24535eece6b5e35730aac57cd9f7 (diff)
parent026bfedb332d8c0dde28c693c177fe993b5df26d (diff)
Merge branch 'master' into mq-filter-stack
Diffstat (limited to 'conf')
-rw-r--r--conf/cf-lex.l5
-rw-r--r--conf/conf.c27
-rw-r--r--conf/conf.h8
3 files changed, 35 insertions, 5 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index 38250d90..1d6cae2c 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -88,7 +88,7 @@ HASH_DEFINE_REHASH_FN(SYM, struct symbol)
HASH(struct keyword) kw_hash;
-static struct sym_scope *conf_this_scope;
+struct sym_scope *conf_this_scope;
linpool *cfg_mem;
@@ -719,7 +719,8 @@ cf_lex_init(int is_cli, struct config *c)
else
BEGIN(INITIAL);
- conf_this_scope = cfg_allocz(sizeof(struct sym_scope));
+ c->root_scope = cfg_allocz(sizeof(struct sym_scope));
+ conf_this_scope = c->root_scope;
conf_this_scope->active = 1;
}
diff --git a/conf/conf.c b/conf/conf.c
index b0980d7e..b21d5213 100644
--- a/conf/conf.c
+++ b/conf/conf.c
@@ -447,6 +447,24 @@ config_undo(void)
return CONF_PROGRESS;
}
+int
+config_status(void)
+{
+ if (shutting_down)
+ return CONF_SHUTDOWN;
+
+ if (configuring)
+ return future_cftype ? CONF_QUEUED : CONF_PROGRESS;
+
+ return CONF_DONE;
+}
+
+btime
+config_timer_status(void)
+{
+ return tm_active(config_timer) ? tm_remains(config_timer) : -1;
+}
+
extern void cmd_reconfig_undo_notify(void);
static void
@@ -477,19 +495,24 @@ config_init(void)
* for switching to an empty configuration.
*/
void
-order_shutdown(void)
+order_shutdown(int gr)
{
struct config *c;
if (shutting_down)
return;
- log(L_INFO "Shutting down");
+ if (!gr)
+ log(L_INFO "Shutting down");
+ else
+ log(L_INFO "Shutting down for graceful restart");
+
c = lp_alloc(config->mem, sizeof(struct config));
memcpy(c, config, sizeof(struct config));
init_list(&c->protos);
init_list(&c->tables);
c->shutdown = 1;
+ c->gr_down = gr;
config_commit(c, RECONFIG_HARD, 0);
shutting_down = 1;
diff --git a/conf/conf.h b/conf/conf.h
index 708a1034..21dc3fa1 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -53,8 +53,10 @@ struct config {
int file_fd; /* File descriptor of main configuration file */
HASH(struct symbol) sym_hash; /* Lexer: symbol hash table */
struct config *fallback; /* Link to regular config for CLI parsing */
+ struct sym_scope *root_scope; /* Scope for root symbols */
int obstacle_count; /* Number of items blocking freeing of this config */
int shutdown; /* This is a pseudo-config for daemon shutdown */
+ int gr_down; /* This is a pseudo-config for graceful restart */
btime load_time; /* When we've got this configuration */
};
@@ -69,11 +71,13 @@ void config_free(struct config *);
int config_commit(struct config *, int type, uint timeout);
int config_confirm(void);
int config_undo(void);
+int config_status(void);
+btime config_timer_status(void);
void config_init(void);
void cf_error(const char *msg, ...) NORET;
void config_add_obstacle(struct config *);
void config_del_obstacle(struct config *);
-void order_shutdown(void);
+void order_shutdown(int gr);
#define RECONFIG_NONE 0
#define RECONFIG_HARD 1
@@ -167,6 +171,8 @@ struct include_file_stack {
extern struct include_file_stack *ifs;
+extern struct sym_scope *conf_this_scope;
+
int cf_lex(void);
void cf_lex_init(int is_cli, struct config *c);
void cf_lex_unwind(void);