#include "system/filesys.h"
#include "system/locale.h"
#include <stdlib.h>
-#include "../include/ctdb_private.h"
+#include "include/ctdb_protocol.h"
+#include "include/ctdb_private.h"
#include "lib/util/dlinklist.h"
}
-/*
- 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;
-}
-
return 0;
}
-/*
- initialise the ctdb daemon for client applications
-
- NOTE: In current code the daemon does not fork. This is for testing purposes only
- and to simplify the code.
-*/
-struct ctdb_context *ctdb_init(struct event_context *ev)
-{
- int ret;
- struct ctdb_context *ctdb;
-
- ctdb = talloc_zero(ev, struct ctdb_context);
- if (ctdb == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " talloc_zero failed.\n"));
- return NULL;
- }
- ctdb->ev = ev;
- ctdb->idr = idr_init(ctdb);
- CTDB_NO_MEMORY_NULL(ctdb, ctdb->idr);
-
- ret = ctdb_set_socketname(ctdb, CTDB_PATH);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_set_socketname failed.\n"));
- talloc_free(ctdb);
- return NULL;
- }
-
- return ctdb;
-}
-
-
/*
set some ctdb flags
*/