From: Ronnie Sahlberg Date: Tue, 11 May 2010 00:58:27 +0000 (+1000) Subject: updates X-Git-Url: http://git.samba.org/?p=sahlberg%2Fctdb.git;a=commitdiff_plain;h=10d64b4ad659c311dde839bdb47efdeeaf2cffbf updates --- diff --git a/Makefile.in b/Makefile.in index cdcb3945..be7a182e 100755 --- a/Makefile.in +++ b/Makefile.in @@ -41,7 +41,7 @@ UTIL_OBJ = lib/util/idtree.o lib/util/db_wrap.o lib/util/strlist.o lib/util/util lib/util/util_time.o lib/util/util_file.o lib/util/fault.o lib/util/substitute.o \ lib/util/signal.o -CTDB_LIB_OBJ = libctdb/ctdb_io.o libctdb/ctdb_connect.o \ +CTDB_LIB_OBJ = libctdb/libctdb.o libctdb/ctdb_io.o \ libctdb/ctdb_client.o libctdb/ctdb_message.o \ libctdb/ctdb_ltdb.o \ libctdb/ctdb_util.o lib/util/debug.o \ diff --git a/include/libctdb.h b/include/libctdb.h index 9a14a7ea..928da565 100644 --- a/include/libctdb.h +++ b/include/libctdb.h @@ -20,38 +20,33 @@ #ifndef _LIBCTDB_H #define _LIBCTDB_H -/* - * initialize the l;ibctdb layer and connect to the daemon +/* all functions except libctdb_connect() and libctdb_service() + * are non-blocking */ + struct ctdb_context *libctdb_connect(const char *addr); -/* - * get the filedescriptor for the event system. - */ int libctdb_get_fd(struct ctdb_context *ctdb); -/* - * what events do we need to trigger on right now - * we always trigger on POLLIN in case ctdb has a packet for us, - * but we also trigger on POLLOUT in case the message queue - * is in use and we need to wait for the socket to become writeable - */ int libctdb_which_events(struct ctdb_context *ctdb); -/* - * called when there are events that libctdb needs to service - */ int libctdb_service(struct ctdb_context *ctdb); +typedef void libctdb_handle; + + typedef void (*get_recmaster_cb)(int32_t status, int32_t recmaster, void *private_data); -struct ctdb_client_control_state * -libctdb_getrecmaster_send_cb(struct ctdb_context *ctdb, + + +libctdb_handle * +libctdb_getrecmaster_cb_send(struct ctdb_context *ctdb, uint32_t destnode, get_recmaster_cb callback, void *private_data); +int libctdb_cancel(libctdb_handle *); #endif diff --git a/libctdb/ctdb_connect.c b/libctdb/libctdb.c similarity index 95% rename from libctdb/ctdb_connect.c rename to libctdb/libctdb.c index de0a5b3e..994c0745 100644 --- a/libctdb/ctdb_connect.c +++ b/libctdb/libctdb.c @@ -128,12 +128,17 @@ int libctdb_service(struct ctdb_context *ctdb) +int libctdb_cancel(libctdb_handle *handle) +{ + talloc_free(handle); + return 0; +} + struct libctdb_control_cb_data { void *callback; void *private_data; }; - static void libctdb_getrecmaster_recv_cb(struct ctdb_client_control_state *state) { @@ -143,11 +148,12 @@ libctdb_getrecmaster_recv_cb(struct ctdb_client_control_state *state) callback(0, state->status, cb_data->private_data); } + /* get the recovery master of a remote node */ -struct ctdb_client_control_state * -libctdb_getrecmaster_send_cb(struct ctdb_context *ctdb, +libctdb_handle * +libctdb_getrecmaster_cb_send(struct ctdb_context *ctdb, uint32_t destnode, get_recmaster_cb callback, void *private_data) @@ -166,7 +172,7 @@ libctdb_getrecmaster_send_cb(struct ctdb_context *ctdb, state->async.fn = libctdb_getrecmaster_recv_cb; state->async.private_data = cb_data; - return state; + return (libctdb_handle *)state; } diff --git a/libctdb/tst.c b/libctdb/tst.c index 6e1cd213..6781746b 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_send_cb(ctdb_context, 0, rm_cb, NULL); + state = libctdb_getrecmaster_cb_send(ctdb_context, 0, rm_cb, NULL); for (;;) { pfd.events = libctdb_which_events(ctdb_context);