summaryrefslogtreecommitdiffstats
path: root/ctdb/include/ctdb.h
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2011-01-14 17:35:31 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2011-01-14 17:38:56 +1100
commitfcd98a7e59641021ed1b81462a154e6385795643 (patch)
tree90f6229c6189b3fda83c740d8d9ea9957b5e34c8 /ctdb/include/ctdb.h
parent6494574d8fd4b9247e45a06cd33472e67b3ed99f (diff)
downloadsamba-fcd98a7e59641021ed1b81462a154e6385795643.tar.gz
samba-fcd98a7e59641021ed1b81462a154e6385795643.tar.xz
samba-fcd98a7e59641021ed1b81462a154e6385795643.zip
LIBCTDB: add support for traverse
(This used to be ctdb commit 9463e04038ba36792583f83bd95c1af322dc283a)
Diffstat (limited to 'ctdb/include/ctdb.h')
-rw-r--r--ctdb/include/ctdb.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h
index 1c6cf353f2..c95c2e1e26 100644
--- a/ctdb/include/ctdb.h
+++ b/ctdb/include/ctdb.h
@@ -291,6 +291,47 @@ bool ctdb_writerecord(struct ctdb_db *ctdb_db,
*/
void ctdb_release_lock(struct ctdb_db *ctdb_db, struct ctdb_lock *lock);
+
+
+/**
+ * ctdb_traverse_callback_t - callback for ctdb_traverse_async.
+ * return 0 - to continue traverse
+ * return 1 - to abort the traverse
+ *
+ * See Also:
+ * ctdb_traverse_async()
+ */
+#define TRAVERSE_STATUS_RECORD 0
+#define TRAVERSE_STATUS_FINISHED 1
+#define TRAVERSE_STATUS_ERROR 2
+typedef int (*ctdb_traverse_callback_t)(struct ctdb_connection *ctdb,
+ struct ctdb_db *ctdb_db,
+ int status,
+ TDB_DATA key,
+ TDB_DATA data,
+ void *private_data);
+
+/**
+ * ctdb_traverse_async - traverse a database.
+ * @ctdb_db: the database handle from ctdb_attachdb/ctdb_attachdb_recv.
+ * @callback: the callback once the record is locked (typesafe).
+ * @cbdata: the argument to callback()
+ *
+ * This returns true on success.
+ * when successfull, the callback will be invoked for each record
+ * until the traversal is finished.
+ *
+ * status ==
+ * TRAVERSE_STATUS_RECORD key/data contains a record.
+ * TRAVERSE_STATUS_FINISHED traverse is finished. key/data is undefined.
+ * TRAVERSE_STATUS_ERROR an error occured during traverse.
+ * key/data is undefined.
+ *
+ * If failure is immediate, false is returned.
+ */
+bool ctdb_traverse_async(struct ctdb_db *ctdb_db,
+ ctdb_traverse_callback_t callback, void *cbdata);
+
/**
* ctdb_message_fn_t - messaging callback for ctdb messages
*
@@ -480,6 +521,7 @@ ctdb_getpublicips_send(struct ctdb_connection *ctdb,
bool ctdb_getpublicips_recv(struct ctdb_connection *ctdb,
struct ctdb_request *req, struct ctdb_all_public_ips **ips);
+
/**
* ctdb_getrecmaster_send - read the recovery master of a node
* @ctdb: the ctdb_connection from ctdb_connect.