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 \
#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
+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)
{
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)
state->async.fn = libctdb_getrecmaster_recv_cb;
state->async.private_data = cb_data;
- return state;
+ return (libctdb_handle *)state;
}
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);