]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Shut down transaction_loop clients more cleanly
authorMartin Schwenke <martin@meltin.net>
Wed, 3 Oct 2018 06:39:16 +0000 (16:39 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 8 Oct 2018 00:46:23 +0000 (02:46 +0200)
A transaction_loop client can exit with a transaction active when its
time limit expires.  This causes a recovery and causes problems with
the test cleanup, which detects unwanted recoveries and fails.

Set a flag when the time limit expires and exit cleanly before the
next transaction is started.

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/src/transaction_loop.c

index a423d6817fdd18e1487c12c4ce5eb9f9b924220e..c6bf35d963d3070bc1fd9e3764573df7197b4aba 100644 (file)
@@ -39,6 +39,7 @@ struct transaction_loop_state {
        struct ctdb_transaction_handle *h;
        uint32_t *old_counter, *counter;
        struct tevent_req *subreq;
+       bool done;
 };
 
 static void transaction_loop_start(struct tevent_req *subreq);
@@ -223,6 +224,20 @@ static void transaction_loop_committed(struct tevent_req *subreq)
                }
        }
 
+       if (state->done) {
+               int i;
+
+               printf("Transaction[%u]: ", ctdb_client_pnn(state->client));
+               for (i=0; i<state->num_nodes; i++) {
+                       printf("%6u ", state->counter[i]);
+               }
+               printf("\n");
+
+               tevent_req_done(req);
+
+               return;
+       }
+
        subreq = ctdb_transaction_start_send(state, state->ev, state->client,
                                             tevent_timeval_current_ofs(
                                                     state->timelimit, 0),
@@ -299,23 +314,16 @@ static void transaction_loop_finish(struct tevent_req *subreq)
        struct transaction_loop_state *state = tevent_req_data(
                req, struct transaction_loop_state);
        bool status;
-       int i;
 
        status = tevent_wakeup_recv(subreq);
        TALLOC_FREE(subreq);
-       TALLOC_FREE(state->subreq);
+
+       state->done = true;
+
        if (! status) {
                tevent_req_error(req, EIO);
                return;
        }
-
-       printf("Transaction[%u]: ", ctdb_client_pnn(state->client));
-       for (i=0; i<state->num_nodes; i++) {
-               printf("%6u ", state->counter[i]);
-       }
-       printf("\n");
-
-       tevent_req_done(req);
 }
 
 static bool transaction_loop_recv(struct tevent_req *req, int *perr)