summaryrefslogtreecommitdiffstats
path: root/ctdb/include
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2009-10-23 15:24:51 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2009-10-23 15:24:51 +1100
commit86d1b4c46582cb0214902cfc5e60b7fe4dc5fdf6 (patch)
treefb34189a34981163c4d64f07838d846620c2d93c /ctdb/include
parentc61c65576954d6a21da74ef91d50654b67febf4d (diff)
Add a mechanism where we can register notifications to be sent out to a SRVID when the client disconnects.
The way to use this is from a client to : 1, first create a message handle and bind it to a SRVID A special prefix for the srvid space has been set aside for samba : Only samba is allowed to use srvid's with the top 32 bits set like this. The lower 32 bits are for samba to use internally. 2, register a "notification" using the new control : CTDB_CONTROL_REGISTER_NOTIFY = 114, This control takes as indata a structure like this : struct ctdb_client_notify_register { uint64_t srvid; uint32_t len; uint8_t notify_data[1]; }; srvid is the srvid used in the space set aside above. len and notify_data is an arbitrary blob. When notifications are later sent out to all clients, this is the payload of that notification message. If a client has registered with control 114 and then disconnects from ctdbd, ctdbd will broadcast a message to that srvid to all nodes/listeners in the cluster. A client can resister itself with as many different srvid's it want, but this is handled through a linked list from the client structure so it mainly designed for "few notifications per client". 3, a client that no longer wants to have a notification set up can deregister using control CTDB_CONTROL_DEREGISTER_NOTIFY = 115, which takes this as arguments : struct ctdb_client_notify_deregister { uint64_t srvid; }; When a client deregisters, there will no longer be sent a message to all other clients when this client disconnects from ctdbd. (This used to be ctdb commit f1b6ee4a55cdca60f93d992f0431d91bf301af2c)
Diffstat (limited to 'ctdb/include')
-rw-r--r--ctdb/include/ctdb.h13
-rw-r--r--ctdb/include/ctdb_private.h8
2 files changed, 20 insertions, 1 deletions
diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h
index abe09a3f96..1ede66205a 100644
--- a/ctdb/include/ctdb.h
+++ b/ctdb/include/ctdb.h
@@ -111,6 +111,10 @@ struct ctdb_call_info {
*/
#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE 0xFD00000000000000LL
+/* A port reserved for samba (top 32 bits)
+ */
+#define CTDB_SRVID_SAMBA_NOTIFY 0xFE00000000000000LL
+
/* used on the domain socket, send a pdu to the local daemon */
#define CTDB_CURRENT_NODE 0xF0000001
/* send a broadcast to all nodes in the cluster, active or not */
@@ -144,6 +148,15 @@ struct ctdb_client_control_state {
} async;
};
+struct ctdb_client_notify_register {
+ uint64_t srvid;
+ uint32_t len;
+ uint8_t notify_data[1];
+};
+
+struct ctdb_client_notify_deregister {
+ uint64_t srvid;
+};
struct event_context;
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 2f4937e60f..ad84628a99 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -160,7 +160,6 @@ typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
int32_t status, TDB_DATA data,
const char *errormsg,
void *private_data);
-
/*
structure describing a connected client in the daemon
*/
@@ -173,6 +172,7 @@ struct ctdb_client {
struct ctdb_tcp_list *tcp_list;
uint32_t db_id;
uint32_t num_persistent_updates;
+ struct ctdb_client_notify_list *notify;
};
@@ -612,6 +612,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_SET_DB_PRIORITY = 111,
CTDB_CONTROL_GET_DB_PRIORITY = 112,
CTDB_CONTROL_TRANSACTION_CANCEL = 113,
+ CTDB_CONTROL_REGISTER_NOTIFY = 114,
+ CTDB_CONTROL_DEREGISTER_NOTIFY = 115,
};
/*
@@ -1501,4 +1503,8 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
+
+int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
+
#endif