client: randomize the transaction_start retry loop:
authorMichael Adam <obnox@samba.org>
Thu, 29 Oct 2009 21:53:44 +0000 (22:53 +0100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 30 Oct 2009 11:02:21 +0000 (22:02 +1100)
instead of sleeping 1 second, sleep between 1 and 100 milliseconds

Michael

client/ctdb_client.c

index ae01638665399c4caf3087cfb37ec6bf1d967204..3e6b833d672ee7322d723a9274b741392a567db1 100644 (file)
@@ -3226,11 +3226,13 @@ again:
                                              CTDB_CURRENT_NODE,
                                              ctdb_db->db_id);
        if (status == 1) {
+               unsigned long int usec = (1000 + random()) % 100000;
                DEBUG(DEBUG_NOTICE, (__location__ " transaction is active "
-                                    "on db_id[0x%08x]. waiting for 1 second\n",
-                                    ctdb_db->db_id));
+                                    "on db_id[0x%08x]. waiting for %lu "
+                                    "microseconds\n",
+                                    ctdb_db->db_id, usec));
                talloc_free(tmp_ctx);
-               sleep(1);
+               usleep(usec);
                goto again;
        }