Add functions for timers initialization and cleanup
This commit is contained in:
parent
3335860dc7
commit
f96d2d5d76
2 changed files with 21 additions and 5 deletions
24
src/net.c
24
src/net.c
|
@ -511,13 +511,29 @@ void retry(void) {
|
|||
timeout_set(&pingtimer, &(struct timeval){0, 0});
|
||||
}
|
||||
|
||||
/*
|
||||
Initialize timers
|
||||
*/
|
||||
void init_timers(void) {
|
||||
timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval){pingtimeout, rand() % 100000});
|
||||
timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval){0, 0});
|
||||
}
|
||||
|
||||
/*
|
||||
Release timers
|
||||
*/
|
||||
|
||||
void exit_timers(void) {
|
||||
timeout_del(&periodictimer);
|
||||
timeout_del(&pingtimer);
|
||||
}
|
||||
|
||||
/*
|
||||
this is where it all happens...
|
||||
*/
|
||||
int main_loop(void) {
|
||||
last_periodic_run_time = now;
|
||||
timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval){pingtimeout, rand() % 100000});
|
||||
timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval){0, 0});
|
||||
init_timers();
|
||||
|
||||
#ifndef HAVE_MINGW
|
||||
signal_t sighup;
|
||||
|
@ -552,8 +568,6 @@ int main_loop(void) {
|
|||
signal_del(&sigalrm);
|
||||
#endif
|
||||
|
||||
timeout_del(&periodictimer);
|
||||
timeout_del(&pingtimer);
|
||||
|
||||
exit_timers();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -220,6 +220,8 @@ extern void regenerate_key(void);
|
|||
extern void update_edge_weight(void);
|
||||
extern void purge(void);
|
||||
extern void retry(void);
|
||||
extern void init_timers(void);
|
||||
extern void exit_timers(void);
|
||||
extern int reload_configuration(void);
|
||||
extern void load_all_nodes(void);
|
||||
extern void try_tx(struct node_t *n, bool);
|
||||
|
|
Loading…
Reference in a new issue