Rev 271: setup the random number generator a bit better in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Thu May 10 03:10:24 GMT 2007


------------------------------------------------------------
revno: 271
revision-id: tridge at samba.org-20070510031023-yhipc23awqwfed3s
parent: tridge at samba.org-20070509224957-9l3bc1ay2rluro28
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Thu 2007-05-10 13:10:23 +1000
message:
  setup the random number generator a bit better
modified:
  direct/ctdb_recoverd.c         recoverd.c-20070503213540-bvxuyd9jm1f7ig90-1
=== modified file 'direct/ctdb_recoverd.c'
--- a/direct/ctdb_recoverd.c	2007-05-09 22:49:57 +0000
+++ b/direct/ctdb_recoverd.c	2007-05-10 03:10:23 +0000
@@ -508,12 +508,11 @@
 	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 @@
 		goto again;
 	}
 	
-
 	/* verify that the recmaster node is still active */
 	for (j=0; j<nodemap->num; 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 @@
 
 
 	/* 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 @@
 	}
 #endif
 
+	srandom(getpid() ^ time(NULL));
+
 	ev = event_context_init(NULL);
 
 	/* initialise ctdb */



More information about the samba-cvs mailing list