shutdown_handler: really shutdown when we are last
If we are a master and we don't have peers, there is no use keeping the sessions alive, when we'll restart we will have forgotten them all. Better gracefully close them, so they can be quickly respawn on restart, instead of having to wait for timeouts.
This commit is contained in:
parent
2229ac6a8a
commit
9daccab8ba
3 changed files with 10 additions and 1 deletions
|
|
@ -754,6 +754,14 @@ void cluster_check_master(void)
|
||||||
// should also update.
|
// should also update.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Returns whether we have peers.
|
||||||
|
//
|
||||||
|
int cluster_have_peers(void)
|
||||||
|
{
|
||||||
|
return num_peers > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check that our session table is validly matching what the
|
// Check that our session table is validly matching what the
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ void cluster_send_ping(time_t basetime);
|
||||||
void cluster_heartbeat(void);
|
void cluster_heartbeat(void);
|
||||||
void cluster_check_master(void);
|
void cluster_check_master(void);
|
||||||
void cluster_check_slaves(void);
|
void cluster_check_slaves(void);
|
||||||
|
int cluster_have_peers(void);
|
||||||
int cmd_show_cluster(struct cli_def *cli, const char *command, char **argv, int argc);
|
int cmd_show_cluster(struct cli_def *cli, const char *command, char **argv, int argc);
|
||||||
int master_forward_pppoe_packet(uint8_t *data, int size, uint8_t codepad);
|
int master_forward_pppoe_packet(uint8_t *data, int size, uint8_t codepad);
|
||||||
|
|
||||||
|
|
|
||||||
2
l2tpns.c
2
l2tpns.c
|
|
@ -5337,7 +5337,7 @@ static void sighup_handler(int sig)
|
||||||
|
|
||||||
static void shutdown_handler(int sig)
|
static void shutdown_handler(int sig)
|
||||||
{
|
{
|
||||||
main_quit = (sig == SIGQUIT) ? QUIT_SHUTDOWN : QUIT_FAILOVER;
|
main_quit = (sig == SIGQUIT || (config->cluster_iam_master && !cluster_have_peers())) ? QUIT_SHUTDOWN : QUIT_FAILOVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sigchild_handler(int sig)
|
static void sigchild_handler(int sig)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue