[SCM] CTDB repository - branch libctdb updated - ctdb-1.0.114-89-gbc00604
Ronnie Sahlberg
sahlberg at samba.org
Tue May 11 20:12:37 MDT 2010
The branch, libctdb has been updated
via bc00604e04f1daa7d31c432c4cae6bafeea72219 (commit)
from a9b8f93e992a911817b5b2a20ae16b50aee90298 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=libctdb
- Log -----------------------------------------------------------------
commit bc00604e04f1daa7d31c432c4cae6bafeea72219
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed May 12 12:11:07 2010 +1000
show gow to use _send() _recv() in the example program
-----------------------------------------------------------------------
Summary of changes:
libctdb/tst.c | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libctdb/tst.c b/libctdb/tst.c
index 51829b5..8f315ca 100644
--- a/libctdb/tst.c
+++ b/libctdb/tst.c
@@ -5,6 +5,11 @@
#include "lib/tdb/include/tdb.h"
#include "include/ctdb.h"
+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);
+}
+
void rm_cb(int32_t status, int32_t recmaster, void *private_data)
{
@@ -14,17 +19,45 @@ void rm_cb(int32_t status, int32_t recmaster, void *private_data)
int main(int argc, char *argv[])
{
struct ctdb_context *ctdb_context;
- struct ctdb_client_control_state *state;
+ ctdb_handle *handle;
struct pollfd pfd;
+ int ret;
+ TDB_DATA msg;
ctdb_context = ctdb_connect("/tmp/ctdb.socket");
pfd.fd = ctdb_get_fd(ctdb_context);
- state = ctdb_getrecmaster_send(ctdb_context, 0, rm_cb, NULL);
+ handle = ctdb_set_message_handler_send(ctdb_context, 55, NULL, msg_h, NULL);
+ if (handle == NULL) {
+ printf("Failed to register message port\n");
+ exit(10);
+ }
+ ret = ctdb_set_message_handler_recv(ctdb_context, ctdb_handle);
+ if (ret != 0) {
+ printf("Failed to receive set_message_handler reply\n");
+ exit(10);
+ }
+
+ msg.dptr="HelloWorld";
+ msg.dsize = strlen(msg.dptr);
+
+ ret = ctdb_send_message(ctdb_context, 0, 55, msg);
+ if (ret != 0) {
+ printf("Failed to send message. Aborting\n");
+ exit(10);
+ }
+
+ handle = ctdb_getrecmaster_send(ctdb_context, 0, rm_cb, NULL);
+ if (handle == NULL) {
+ printf("Failed to send get_recmaster control\n");
+ exit(10);
+ }
+
for (;;) {
+
pfd.events = ctdb_which_events(ctdb_context);
if (poll(&pfd, 1, -1) < 0) {
printf("Poll failed");
--
CTDB repository
More information about the samba-cvs
mailing list