[SCM] CTDB repository - branch master updated - ctdb-1.0.114-119-g3f651eb
Ronnie Sahlberg
sahlberg at samba.org
Tue Jun 1 18:38:49 MDT 2010
The branch, master has been updated
via 3f651eb8d71c7af0268460bc4b1476112140b290 (commit)
via 01c2acdf3cb29bb44c74d9d792cf1d3706534ad2 (commit)
from 112d252b2ab614eeac38e4a1658cd1e85f6eb829 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 3f651eb8d71c7af0268460bc4b1476112140b290
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed Jun 2 10:37:00 2010 +1000
link ctdb with libctdb and connect to the daemon both the old way and by using libctdb
update the function "control_pnn()" to use libctdb to ask the daemon for the pnn
commit 01c2acdf3cb29bb44c74d9d792cf1d3706534ad2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed Jun 2 10:36:19 2010 +1000
add a sync wrapper for the getpnn control
-----------------------------------------------------------------------
Summary of changes:
Makefile.in | 4 ++--
libctdb/sync.c | 17 +++++++++++++++++
tools/ctdb.c | 21 +++++++++++++++++----
3 files changed, 36 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/Makefile.in b/Makefile.in
index b72e90e..dd7864e 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -118,9 +118,9 @@ bin/scsi_io: $(CTDB_CLIENT_OBJ) utils/scsi_io/scsi_io.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ utils/scsi_io/scsi_io.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
-bin/ctdb: $(CTDB_CLIENT_OBJ) tools/ctdb.o tools/ctdb_vacuum.o
+bin/ctdb: $(CTDB_CLIENT_OBJ) tools/ctdb.o tools/ctdb_vacuum.o libctdb/libctdb.a
@echo Linking $@
- @$(CC) $(CFLAGS) -o $@ tools/ctdb.o tools/ctdb_vacuum.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
+ @$(CC) $(CFLAGS) -o $@ tools/ctdb.o tools/ctdb_vacuum.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) libctdb/libctdb.a
bin/smnotify: utils/smnotify/gen_xdr.o utils/smnotify/gen_smnotify.o utils/smnotify/smnotify.o $(POPT_OBJ)
@echo Linking $@
diff --git a/libctdb/sync.c b/libctdb/sync.c
index dfafa05..df86552 100644
--- a/libctdb/sync.c
+++ b/libctdb/sync.c
@@ -92,3 +92,20 @@ struct ctdb_db *ctdb_attachdb(struct ctdb_connection *ctdb,
}
return ret;
}
+
+int ctdb_getpnn(struct ctdb_connection *ctdb,
+ uint32_t destnode, uint32_t *pnn)
+{
+ struct ctdb_request *req;
+ bool done = false;
+ int ret = -1;
+
+ req = wait_for(ctdb,
+ ctdb_getpnn_send(ctdb, destnode, set, &done),
+ &done);
+ if (req != NULL) {
+ ret = ctdb_getpnn_recv(req, pnn);
+ ctdb_request_free(req);
+ }
+ return ret;
+}
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 3fad1e1..6990851 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -26,6 +26,7 @@
#include "system/locale.h"
#include "popt.h"
#include "cmdline.h"
+#include "../include/ctdb.h"
#include "../include/ctdb_client.h"
#include "../include/ctdb_private.h"
#include "../common/rb_tree.h"
@@ -35,6 +36,8 @@
#define ERR_NONODE 21 /* node does not exist */
#define ERR_DISNODE 22 /* node is disconnected */
+struct ctdb_connection *ctdb_connection;
+
static void usage(void);
static struct {
@@ -365,11 +368,12 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
*/
static int control_pnn(struct ctdb_context *ctdb, int argc, const char **argv)
{
- int mypnn;
+ uint32_t mypnn;
+ int ret;
- mypnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
- if (mypnn == -1) {
- DEBUG(DEBUG_ERR, ("Unable to get pnn from local node."));
+ ret = ctdb_getpnn(ctdb_connection, options.pnn, &mypnn);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to get pnn from node."));
return -1;
}
@@ -4536,6 +4540,7 @@ int main(int argc, const char *argv[])
for (i=0;i<ARRAY_SIZE(ctdb_commands);i++) {
if (strcmp(control, ctdb_commands[i].name) == 0) {
int j;
+ const char *socket_name;
if (ctdb_commands[i].without_daemon == true) {
close(2);
@@ -4544,6 +4549,14 @@ int main(int argc, const char *argv[])
/* initialise ctdb */
ctdb = ctdb_cmdline_client(ev);
+ /* initialize a libctdb connection as well */
+ socket_name = ctdb_get_socketname(ctdb);
+ ctdb_connection = ctdb_connect(socket_name);
+ if (ctdb_connection == NULL) {
+ fprintf(stderr, "Failed to connect to daemon from libctdb\n");
+ exit(1);
+ }
+
if (ctdb_commands[i].without_daemon == false) {
if (ctdb == NULL) {
DEBUG(DEBUG_ERR, ("Failed to init ctdb\n"));
--
CTDB repository
More information about the samba-cvs
mailing list