r24643: add a ctdb_fetch() function to the ctdb client code
authorAndrew Tridgell <tridge@samba.org>
Fri, 24 Aug 2007 02:38:09 +0000 (02:38 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:02:29 +0000 (15:02 -0500)
(This used to be commit 5705ee04498780d8ca89290e85b8ec831f0a185d)

source4/cluster/ctdb/client/ctdb_client.c

index d85f883b22503d0a325df7713b68e4357576eaff..b569a69c8d8d3bcce5f241288140751a52b4ce3d 100644 (file)
@@ -637,6 +637,30 @@ int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data)
        return ctdb_ltdb_store(h->ctdb_db, h->key, &h->header, data);
 }
 
+/*
+  non-locking fetch of a record
+ */
+int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
+              TDB_DATA key, TDB_DATA *data)
+{
+       struct ctdb_call call;
+       int ret;
+
+       call.call_id = CTDB_FETCH_FUNC;
+       call.call_data.dptr = NULL;
+       call.call_data.dsize = 0;
+
+       ret = ctdb_call(ctdb_db, &call);
+
+       if (ret == 0) {
+               *data = call.reply_data;
+               talloc_steal(mem_ctx, data->dptr);
+       }
+
+       return ret;
+}
+
+
 struct ctdb_client_control_state {
        struct ctdb_context *ctdb;
        uint32_t reqid;