From: Andrew Tridgell Date: Thu, 10 May 2007 03:10:23 +0000 (+1000) Subject: setup the random number generator a bit better X-Git-Tag: tevent-0.9.20~348^2~2760 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=50390bcb182c2fb182f356fcc8437a4e0922c4f8;p=thirdparty%2Fsamba.git setup the random number generator a bit better (This used to be ctdb commit 708585eb0ed31b0df6543a1d7a20b82e751877c2) --- diff --git a/ctdb/direct/ctdb_recoverd.c b/ctdb/direct/ctdb_recoverd.c index ec122cb5ecf..e9441b82d20 100644 --- a/ctdb/direct/ctdb_recoverd.c +++ b/ctdb/direct/ctdb_recoverd.c @@ -508,12 +508,11 @@ static void election_handler(struct ctdb_context *ctdb, uint64_t srvid, struct election_message *em = (struct election_message *)data.dptr; TALLOC_CTX *mem_ctx; - mem_ctx = talloc_new(ctdb); - if (em->vnn==ctdb_get_vnn(ctdb)) { - talloc_free(mem_ctx); return; } + + mem_ctx = talloc_new(ctdb); /* someone called an election. check their election data and if we disagree and we would rather be the elected node, @@ -628,13 +627,12 @@ again: goto again; } - /* verify that the recmaster node is still active */ for (j=0; jnum; j++) { if (nodemap->nodes[j].vnn==recmaster) { break; } - } + } if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) { DEBUG(0, ("Recmaster node %u no longer available. Force reelection\n", nodemap->nodes[j].vnn)); force_election(ctdb, mem_ctx, vnn, nodemap); @@ -736,7 +734,7 @@ again: /* there better be the same number of lmasters in the vnn map - as there are active nodes or well have to do a recovery + as there are active nodes or we will have to do a recovery */ if (vnnmap->size != num_active) { DEBUG(0, (__location__ "The vnnmap count is different from the number of active nodes. %d vs %d\n", vnnmap->size, num_active)); @@ -856,6 +854,8 @@ int main(int argc, const char *argv[]) } #endif + srandom(getpid() ^ time(NULL)); + ev = event_context_init(NULL); /* initialise ctdb */