change tst.c example to use message id ports from the range reserved for test purposes
+/*
+ Messaging serverid ports
+*/
+/*
+ a message handler ID meaning "give me all messages"
+ */
+#define CTDB_SRVID_ALL (~(uint64_t)0)
+
+/*
+ The top 32 bits of the server id represents the owner of
+ this part of the srvid space
+*/
+#define CTDB_SRVID_MASK 0xFFFFFFFF00000000LL
+
+
+/*
+ Samba owns all message handler IDs where the top 32 bits are all zero
+*/
+#define CTDB_SRVID_SAMBA 0x0000000000000000
+#define CTDB_IS_SAMBA_SRVID ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_SAMBA)
+
+/*
+ Server ids reserved for testing
+*/
+#define CTDB_SRVID_TEST 0x0000000100000000
+#define CTDB_IS_TEST_SRVID ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_TEST)
+
+/*
+ srvid type : RECOVERY
+*/
+#define CTDB_SRVID_RECOVERY 0xF100000000000000LL
+
+/*
+ a message handler ID meaning that the cluster has been reconfigured
+ */
+#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
+
+/*
+ a message handler ID meaning that an IP address has been released
+ */
+#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
+
+/*
+ a message ID to set the node flags in the recovery daemon
+ */
+#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
+
+/*
+ a message ID to ask the recovery daemon to update the expected node
+ assignment for a public ip
+ */
+#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
+
+/*
+ a message to tell the recovery daemon to fetch a set of records
+ */
+#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
+
+/*
+ a message to tell the recovery daemon to write a talloc memdump
+ to the log
+ */
+#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
+
+/*
+ a message ID to get the recovery daemon to push the node flags out
+ */
+#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
+
+/*
+ a message ID to get the recovery daemon to reload the nodes file
+ */
+#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
+
+/*
+ a message ID to get the recovery daemon to perform a takeover run
+ */
+#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
+
+/* A message id to ask the recovery daemon to temporarily disable the
+ public ip checks
+*/
+#define CTDB_SRVID_DISABLE_IP_CHECK 0xFC00000000000000LL
+
+/* A dummy port used for sending back ipreallocate resposnes to the main
+ daemon
+*/
+#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE 0xFD00000000000000LL
+
+/* A port reserved for samba (top 32 bits)
+ */
+#define CTDB_SRVID_SAMBA_NOTIFY 0xFE00000000000000LL
+
/*
* messaging functions
* these functions provide a messaging layer for applications to communicate
*/
#define CTDB_FLAG_TORTURE (1<<1)
-/*
- The top 32 bits of the server id represents the owner of
- this part of the srvid space
-*/
-#define CTDB_SRVID_MASK 0xFFFFFFFF00000000LL
-
-
-/*
- Samba owns all message handler IDs where the top 32 bits are all zero
-*/
-#define CTDB_SRVID_SAMBA 0x0000000000000000
-#define CTDB_IS_SAMBA_SRVID ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_SAMBA)
-
-/*
- Server ids reserved for testing
-*/
-#define CTDB_SRVID_TEST 0x0000000100000000
-#define CTDB_IS_TEST_SRVID ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_TEST)
-
-/*
- a message handler ID meaning "give me all messages"
- */
-#define CTDB_SRVID_ALL (~(uint64_t)0)
-
-/*
- srvid type : RECOVERY
-*/
-#define CTDB_SRVID_RECOVERY 0xF100000000000000LL
-
-/*
- a message handler ID meaning that the cluster has been reconfigured
- */
-#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
-
-/*
- a message handler ID meaning that an IP address has been released
- */
-#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
-
-/*
- a message ID to set the node flags in the recovery daemon
- */
-#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
-
-/*
- a message ID to ask the recovery daemon to update the expected node
- assignment for a public ip
- */
-#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
-
-/*
- a message to tell the recovery daemon to fetch a set of records
- */
-#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
-
-/*
- a message to tell the recovery daemon to write a talloc memdump
- to the log
- */
-#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
-
-/*
- a message ID to get the recovery daemon to push the node flags out
- */
-#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
-
-/*
- a message ID to get the recovery daemon to reload the nodes file
- */
-#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
-
-/*
- a message ID to get the recovery daemon to perform a takeover run
- */
-#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
-
-/* A message id to ask the recovery daemon to temporarily disable the
- public ip checks
-*/
-#define CTDB_SRVID_DISABLE_IP_CHECK 0xFC00000000000000LL
-
-/* A dummy port used for sending back ipreallocate resposnes to the main
- daemon
-*/
-#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE 0xFD00000000000000LL
-
-/* A port reserved for samba (top 32 bits)
- */
-#define CTDB_SRVID_SAMBA_NOTIFY 0xFE00000000000000LL
/* the key used for transaction locking on persistent databases */
void msg_h(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data, void *private_data)
{
- printf("Message received on port %d : %s\n", (int)srvid, data.dptr);
+ printf("Message received on port 0x%016llx : %s\n", srvid, data.dptr);
}
ctdb = ctdb_connect("/tmp/ctdb.socket");
- handle = ctdb_set_message_handler_send(ctdb, 55, NULL, msg_h, NULL);
+ handle = ctdb_set_message_handler_send(ctdb, CTDB_SRVID_TEST|55, NULL, msg_h, NULL);
if (handle == NULL) {
printf("Failed to register message port\n");
exit(10);
msg.dptr="HelloWorld";
msg.dsize = strlen(msg.dptr);
- ret = ctdb_send_message(ctdb, 0, 55, msg);
+ ret = ctdb_send_message(ctdb, 0, CTDB_SRVID_TEST|55, msg);
if (ret != 0) {
printf("Failed to send message. Aborting\n");
exit(10);