move messaging functions into libctdb
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 11 May 2010 18:53:44 +0000 (04:53 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 11 May 2010 18:53:44 +0000 (04:53 +1000)
client/ctdb_client.c
include/ctdb.h
include/ctdb_protocol.h

index 1afa66a353a4bc78252bddf957795947d4fd603b..f8e98b54fc66d9856212cfcd445e0e615bc189f8 100644 (file)
@@ -95,49 +95,6 @@ int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call)
 }
 
 
-/*
-  tell the daemon what messaging srvid we will use, and register the message
-  handler function in the client
-*/
-int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
-                            ctdb_message_fn_t handler,
-                            void *private_data)
-                                   
-{
-       int res;
-       int32_t status;
-       
-       res = ctdb_control(ctdb, CTDB_CURRENT_NODE, srvid, CTDB_CONTROL_REGISTER_SRVID, 0, 
-                          tdb_null, NULL, NULL, &status, NULL, NULL);
-       if (res != 0 || status != 0) {
-               DEBUG(DEBUG_ERR,("Failed to register srvid %llu\n", (unsigned long long)srvid));
-               return -1;
-       }
-
-       /* also need to register the handler with our own ctdb structure */
-       return ctdb_register_message_handler(ctdb, ctdb, srvid, handler, private_data);
-}
-
-/*
-  tell the daemon we no longer want a srvid
-*/
-int ctdb_remove_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data)
-{
-       int res;
-       int32_t status;
-       
-       res = ctdb_control(ctdb, CTDB_CURRENT_NODE, srvid, CTDB_CONTROL_DEREGISTER_SRVID, 0, 
-                          tdb_null, NULL, NULL, &status, NULL, NULL);
-       if (res != 0 || status != 0) {
-               DEBUG(DEBUG_ERR,("Failed to deregister srvid %llu\n", (unsigned long long)srvid));
-               return -1;
-       }
-
-       /* also need to register the handler with our own ctdb structure */
-       ctdb_deregister_message_handler(ctdb, srvid, private_data);
-       return 0;
-}
-
 
 
 
index dd5361c1782b0e1adb117e0ca33ffd13a5f75812..df9f54c10c9a74226b6c607bd46699e05633d67e 100644 (file)
@@ -39,6 +39,21 @@ typedef void ctdb_handle;
 int ctdb_cancel(ctdb_handle *);
 
 
+
+/*
+ * messaging functions 
+ */
+typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, TDB_DATA data, void *);
+
+int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, ctdb_message_fn_t handler, void *private_data);
+
+int ctdb_remove_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
+
+int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn, uint64_t srvid, TDB_DATA data);
+
+
+
+
 /*
  * functions to read the recovery master of a node
  */
index cf4305f28392c7621bb0f8336a3db99e29f1c0bf..e1d2e4e5cd5b4057ab7c9c20a4c392cb38ec39ed 100644 (file)
@@ -266,22 +266,11 @@ uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
 */
 uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb);
 
-/* setup a handler for ctdb messages */
-typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, 
-                                 TDB_DATA data, void *);
-int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
-                            ctdb_message_fn_t handler,
-                            void *private_data);
-
 
 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
 struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
 int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call);
 
-/* send a ctdb message */
-int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn,
-                     uint64_t srvid, TDB_DATA data);
-
 
 /* 
    Fetch a ctdb record from a remote node