]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
setup the random number generator a bit better
authorAndrew Tridgell <tridge@samba.org>
Thu, 10 May 2007 03:10:23 +0000 (13:10 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 10 May 2007 03:10:23 +0000 (13:10 +1000)
(This used to be ctdb commit 708585eb0ed31b0df6543a1d7a20b82e751877c2)

ctdb/direct/ctdb_recoverd.c

index ec122cb5ecfb250a784487ecea62ad7a536268d1..e9441b82d20bb1187573b159c77d5b0a42d98147 100644 (file)
@@ -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; 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 @@ 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 */