* functions to attach to a database
* if the database does not exist it will be created.
*
- * Use ctdb_free() to release the returned ctdb_db_context when finished.
+ * You have to free the handle with ctdb_free() when finished with it.
*/
struct ctdb_db_context;
-typedef void (*ctdb_attachdb_cb)(int32_t status, struct ctdb_db_context *ctdb_db, void *private_data);
+typedef void (*ctdb_attachdb_cb)(int32_t status, ctdb_handle *, struct ctdb_db_context *ctdb_db, void *private_data);
ctdb_handle *
ctdb_attachdb_send(struct ctdb_context *ctdb,
struct ctdb_db_context **);
+/*
+ * functions to read a record from the database
+ * when the callback is invoked, the client will hold an exclusive lock
+ * on the record, until the handle is ctdb_free()d.
+ * the client MUST NOT block during holding this lock and MUST
+ * release it quickly by performing ctdb_free(handle).
+ *
+ * When the handle is freed, data is freed too, so make sure to copy the data
+ * before freeing the handle.
+ */
+typedef void (*ctdb_readrecordlock_cb)(int32_t status, ctdb_handle *handle, TDB_DATA data, void *private_data);
+
+ctdb_handle *
+ctdb_readrecordlock_send(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db_context,
+ TDB_DATA key,
+ ctdb_readrecordlock_cb callback,
+ void *private_data);
+int ctdb_readrecordlock_recv(struct ctdb_context *ctdb,
+ ctdb_handle *handle,
+ TDB_DATA **data);
+int ctdb_readrecordlock(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db_context,
+ TDB_DATA key,
+ TDB_DATA **data);
+
+
+
+/*
+ * Function to write data to a record
+ * This function may ONLY be called while holding a lock to the record
+ * created by ctdb_readrecordlock*
+ * Either from the callback provided to ctdb_readrecordlock_send()
+ * or after calling ctdb_readrecordlock_recv() but before calling
+ * ctdb_free() to release the handle.
+ */
+int ctdb_writerecord(ctdb_handle *handle,
+ TDB_DATA key,
+ TDB_DATA data);
+
+
/*
* messaging functions