Nest: Update to new timers

This commit is contained in:
Ondrej Zajicek (work) 2017-06-21 14:43:49 +02:00
parent cc881bd155
commit 3e405fb188
5 changed files with 13 additions and 14 deletions

View file

@ -307,7 +307,7 @@ config_done(void *unused UNUSED)
* config_commit - commit a configuration * config_commit - commit a configuration
* @c: new configuration * @c: new configuration
* @type: type of reconfiguration (RECONFIG_SOFT or RECONFIG_HARD) * @type: type of reconfiguration (RECONFIG_SOFT or RECONFIG_HARD)
* @timeout: timeout for undo (or 0 for no timeout) * @timeout: timeout for undo (in seconds; or 0 for no timeout)
* *
* When a configuration is parsed and prepared for use, the * When a configuration is parsed and prepared for use, the
* config_commit() function starts the process of reconfiguration. * config_commit() function starts the process of reconfiguration.
@ -331,7 +331,7 @@ config_done(void *unused UNUSED)
* are accepted. * are accepted.
*/ */
int int
config_commit(struct config *c, int type, int timeout) config_commit(struct config *c, int type, uint timeout)
{ {
if (shutting_down) if (shutting_down)
{ {
@ -340,10 +340,10 @@ config_commit(struct config *c, int type, int timeout)
} }
undo_available = 1; undo_available = 1;
if (timeout > 0) if (timeout)
tm_start(config_timer, timeout); tm2_start(config_timer, timeout S);
else else
tm_stop(config_timer); tm2_stop(config_timer);
if (configuring) if (configuring)
{ {

View file

@ -41,7 +41,7 @@ struct config {
struct timeformat tf_proto; /* Time format for 'show protocol' */ struct timeformat tf_proto; /* Time format for 'show protocol' */
struct timeformat tf_log; /* Time format for the logfile */ struct timeformat tf_log; /* Time format for the logfile */
struct timeformat tf_base; /* Time format for other purposes */ struct timeformat tf_base; /* Time format for other purposes */
u32 gr_wait; /* Graceful restart wait timeout */ u32 gr_wait; /* Graceful restart wait timeout (sec) */
int cli_debug; /* Tracing of CLI connections and commands */ int cli_debug; /* Tracing of CLI connections and commands */
int latency_debug; /* I/O loop tracks duration of each event */ int latency_debug; /* I/O loop tracks duration of each event */
@ -68,7 +68,7 @@ struct config *config_alloc(const char *name);
int config_parse(struct config *); int config_parse(struct config *);
int cli_parse(struct config *); int cli_parse(struct config *);
void config_free(struct config *); void config_free(struct config *);
int config_commit(struct config *, int type, int timeout); int config_commit(struct config *, int type, uint timeout);
int config_confirm(void); int config_confirm(void);
int config_undo(void); int config_undo(void);
void config_init(void); void config_init(void);

View file

@ -1083,9 +1083,8 @@ graceful_restart_init(void)
} }
graceful_restart_state = GRS_ACTIVE; graceful_restart_state = GRS_ACTIVE;
gr_wait_timer = tm_new(proto_pool); gr_wait_timer = tm2_new_init(proto_pool, graceful_restart_done, NULL, 0, 0);
gr_wait_timer->hook = graceful_restart_done; tm2_start(gr_wait_timer, config->gr_wait S);
tm_start(gr_wait_timer, config->gr_wait);
} }
/** /**
@ -1182,7 +1181,7 @@ channel_graceful_restart_unlock(struct channel *c)
graceful_restart_locks--; graceful_restart_locks--;
if ((graceful_restart_state == GRS_ACTIVE) && !graceful_restart_locks) if ((graceful_restart_state == GRS_ACTIVE) && !graceful_restart_locks)
tm_start(gr_wait_timer, 0); tm2_start(gr_wait_timer, 0);
} }
@ -1329,7 +1328,7 @@ proto_schedule_down(struct proto *p, byte restart, byte code)
p->down_sched = restart ? PDS_RESTART : PDS_DISABLE; p->down_sched = restart ? PDS_RESTART : PDS_DISABLE;
p->down_code = code; p->down_code = code;
tm_start_max(proto_shutdown_timer, restart ? 2 : 0); tm2_start_max(proto_shutdown_timer, restart ? 250 MS : 0);
} }

View file

@ -303,7 +303,7 @@ cmd_reconfig_undo_notify(void)
} }
void void
cmd_reconfig(char *name, int type, int timeout) cmd_reconfig(char *name, int type, uint timeout)
{ {
if (cli_access_restricted()) if (cli_access_restricted())
return; return;

View file

@ -22,7 +22,7 @@ void async_config(void);
void async_dump(void); void async_dump(void);
void async_shutdown(void); void async_shutdown(void);
void cmd_check_config(char *name); void cmd_check_config(char *name);
void cmd_reconfig(char *name, int type, int timeout); void cmd_reconfig(char *name, int type, uint timeout);
void cmd_reconfig_confirm(void); void cmd_reconfig_confirm(void);
void cmd_reconfig_undo(void); void cmd_reconfig_undo(void);
void cmd_shutdown(void); void cmd_shutdown(void);