X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/a15bd8df2bba80c67555ff562d4e1d3b66fc6a2c..aa77d4f89aa291e851c9be8a64ecfdb1434e83c9:/cluster.c diff --git a/cluster.c b/cluster.c index 725adc1..8f9c01e 100644 --- a/cluster.c +++ b/cluster.c @@ -1,6 +1,6 @@ // L2TPNS Clustering Stuff -char const *cvs_id_cluster = "$Id: cluster.c,v 1.26.2.10 2005/05/23 13:48:29 bodea Exp $"; +char const *cvs_id_cluster = "$Id: cluster.c,v 1.26.2.12 2005/07/03 02:58:06 bodea Exp $"; #include #include @@ -523,9 +523,14 @@ void cluster_check_master(void) return; // Everything's ok! config->cluster_last_hb = TIME + 1; // Just the one election thanks. + config->cluster_master_address = 0; LOG(0, 0, 0, "Master timed out! Holding election...\n"); + // In the process of shutting down, can't be master + if (main_quit) + return; + for (i = have_peers = 0; i < num_peers; i++) { if ((peers[i].timestamp + config->cluster_hb_timeout) < t) @@ -554,7 +559,6 @@ void cluster_check_master(void) // to become a master!!! config->cluster_iam_master = 1; - config->cluster_master_address = 0; LOG(0, 0, 0, "I am declaring myself the master!\n"); @@ -1239,8 +1243,7 @@ static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t // Note that after a clean failover, the cluster_master_address // is cleared, so this doesn't run. // - if (config->cluster_master_address && addr != config->cluster_master_address - && (config->cluster_last_hb + config->cluster_hb_timeout - 11) > TIME) { + if (config->cluster_master_address && addr != config->cluster_master_address) { LOG(0, 0, 0, "Ignoring stray heartbeat from %s, current master %s has not yet timed out (last heartbeat %.1f seconds ago).\n", fmtaddr(addr, 0), fmtaddr(config->cluster_master_address, 1), 0.1 * (TIME - config->cluster_last_hb));