ctdb-recoverd/vacuum: move fetch loop back into fetch handler.
authorMichael Adam <obnox@samba.org>
Tue, 2 Jun 2015 20:17:03 +0000 (22:17 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 5 Jun 2015 09:28:23 +0000 (11:28 +0200)
With the processing of one element factored out,
it is more natural to have the actual loop inside the
handler function. This also makes the talloc/free
bracked around the loop more obvious.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c

index e5a4a401e15b954d143f003c7d4b7ce0383c9771..002191f66288d51d0199f91e2c9396be522f9fdf 100644 (file)
@@ -1070,29 +1070,6 @@ static bool vacuum_fetch_process_one(struct ctdb_db_context *ctdb_db,
        return true;
 }
 
-/*
-  process the next element from the vacuum list
-*/
-static void vacuum_fetch_next(struct vacuum_info *v)
-{
-       while (v->recs->count) {
-               struct ctdb_rec_data *r;
-               bool ok;
-
-               r = v->r;
-
-               ok = vacuum_fetch_process_one(v->ctdb_db, v->rec->ctdb->pnn, r);
-               if (!ok) {
-                       break;
-               }
-
-               v->r = (struct ctdb_rec_data *)(r->length + (uint8_t *)r);
-               v->recs->count--;
-       }
-
-       talloc_free(v);
-}
-
 
 /*
   destroy a vacuum info structure
@@ -1190,7 +1167,21 @@ static void vacuum_fetch_handler(struct ctdb_context *ctdb, uint64_t srvid,
 
        talloc_set_destructor(v, vacuum_info_destructor);
 
-       vacuum_fetch_next(v);
+       while (v->recs->count) {
+               bool ok;
+
+               r = v->r;
+
+               ok = vacuum_fetch_process_one(v->ctdb_db, v->rec->ctdb->pnn, r);
+               if (!ok) {
+                       break;
+               }
+
+               v->r = (struct ctdb_rec_data *)(r->length + (uint8_t *)r);
+               v->recs->count--;
+       }
+
+       talloc_free(v);
 
 done:
        talloc_free(tmp_ctx);