[SCM] CTDB repository - branch libctdb updated - ctdb-1.0.114-81-g2dbbc98
Ronnie Sahlberg
sahlberg at samba.org
Mon May 10 19:28:11 MDT 2010
The branch, libctdb has been updated
via 2dbbc98985783dc14462371ffaf1febf2484a79d (commit)
from 10d64b4ad659c311dde839bdb47efdeeaf2cffbf (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=libctdb
- Log -----------------------------------------------------------------
commit 2dbbc98985783dc14462371ffaf1febf2484a79d
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue May 11 11:26:48 2010 +1000
add libctdb getrecmaster control recv function and
a sync version of getrecmaster
-----------------------------------------------------------------------
Summary of changes:
include/libctdb.h | 9 ++++++++-
libctdb/libctdb.c | 44 ++++++++++++++++++++++++++++++++++++++------
libctdb/tst.c | 2 +-
3 files changed, 47 insertions(+), 8 deletions(-)
Changeset truncated at 500 lines:
diff --git a/include/libctdb.h b/include/libctdb.h
index 928da56..6a1926b 100644
--- a/include/libctdb.h
+++ b/include/libctdb.h
@@ -42,10 +42,17 @@ typedef void (*get_recmaster_cb)(int32_t status, int32_t recmaster, void *privat
libctdb_handle *
-libctdb_getrecmaster_cb_send(struct ctdb_context *ctdb,
+libctdb_getrecmaster_send(struct ctdb_context *ctdb,
uint32_t destnode,
get_recmaster_cb callback,
void *private_data);
+int libctdb_getrecmaster_recv(struct ctdb_context *ctdb,
+ libctdb_handle *handle,
+ uint32_t *recmaster);
+int libctdb_getrecmaster(struct ctdb_context *ctdb,
+ uint32_t destnode,
+ uint32_t *recmaster);
+
int libctdb_cancel(libctdb_handle *);
diff --git a/libctdb/libctdb.c b/libctdb/libctdb.c
index 994c074..e3a7c1a 100644
--- a/libctdb/libctdb.c
+++ b/libctdb/libctdb.c
@@ -153,7 +153,7 @@ libctdb_getrecmaster_recv_cb(struct ctdb_client_control_state *state)
get the recovery master of a remote node
*/
libctdb_handle *
-libctdb_getrecmaster_cb_send(struct ctdb_context *ctdb,
+libctdb_getrecmaster_send(struct ctdb_context *ctdb,
uint32_t destnode,
get_recmaster_cb callback,
void *private_data)
@@ -165,17 +165,49 @@ libctdb_getrecmaster_cb_send(struct ctdb_context *ctdb,
CTDB_CONTROL_GET_RECMASTER, 0, tdb_null,
ctdb, NULL, NULL);
- cb_data = talloc(state, struct libctdb_control_cb_data);
- cb_data->callback = callback;
- cb_data->private_data = private_data;
+ if (callback != NULL) {
+ cb_data = talloc(state, struct libctdb_control_cb_data);
+ cb_data->callback = callback;
+ cb_data->private_data = private_data;
- state->async.fn = libctdb_getrecmaster_recv_cb;
- state->async.private_data = cb_data;
+ state->async.fn = libctdb_getrecmaster_recv_cb;
+ state->async.private_data = cb_data;
+ }
return (libctdb_handle *)state;
}
+int libctdb_getrecmaster_recv(struct ctdb_context *ctdb, libctdb_handle *handle, uint32_t *recmaster)
+{
+ struct ctdb_client_control_state *state = talloc_get_type(handle, struct ctdb_client_control_state);
+ int ret;
+ int32_t res;
+
+ ret = ctdb_control_recv(ctdb, state, state, NULL, &res, NULL);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " libctdb_getrecmaster_recv failed\n"));
+ return -1;
+ }
+
+ if (recmaster) {
+ *recmaster = (uint32_t)res;
+ }
+
+ return 0;
+}
+
+int libctdb_getrecmaster(struct ctdb_context *ctdb, uint32_t destnode, uint32_t *recmaster)
+{
+ struct ctdb_client_control_state *state;
+
+ state = libctdb_getrecmaster_send(ctdb, destnode, NULL, recmaster);
+ if (state == NULL) {
+ DEBUG(DEBUG_ERR,(__location__ " libctdb_getrecmaster_send() failed.\n"));
+ return -1;
+ }
+ return libctdb_getrecmaster_recv(ctdb, state, recmaster);
+}
diff --git a/libctdb/tst.c b/libctdb/tst.c
index 6781746..251c376 100644
--- a/libctdb/tst.c
+++ b/libctdb/tst.c
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
pfd.fd = libctdb_get_fd(ctdb_context);
- state = libctdb_getrecmaster_cb_send(ctdb_context, 0, rm_cb, NULL);
+ state = libctdb_getrecmaster_send(ctdb_context, 0, rm_cb, NULL);
for (;;) {
pfd.events = libctdb_which_events(ctdb_context);
--
CTDB repository
More information about the samba-cvs
mailing list