updates
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 11 May 2010 00:58:27 +0000 (10:58 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 11 May 2010 00:58:27 +0000 (10:58 +1000)
Makefile.in
include/libctdb.h
libctdb/libctdb.c [moved from libctdb/ctdb_connect.c with 95% similarity]
libctdb/tst.c

index cdcb394557669b80b3d3297c6f708bd1a84fa8c6..be7a182e702b476a77687f2e7a6a335973e6f173 100755 (executable)
@@ -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 \
index 9a14a7eab7c16a4fd25adac8eb0f902ae59feef2..928da5653cdc10ded71393103457e8a98c0be69e 100644 (file)
 #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
similarity index 95%
rename from libctdb/ctdb_connect.c
rename to libctdb/libctdb.c
index de0a5b3e5c10efcf8ced7e7046c4c3b453962ce6..994c074591143209c8d5a3f725e553e927ed8cd5 100644 (file)
@@ -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;
 }
 
 
index 6e1cd2134f07dc9fdd95dfd126f892bd7b9833e1..6781746bbe29b3cb816c668ca4249965148d21c3 100644 (file)
@@ -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);