]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
report number of clients in ping
authorAndrew Tridgell <tridge@samba.org>
Sat, 28 Apr 2007 13:15:21 +0000 (15:15 +0200)
committerAndrew Tridgell <tridge@samba.org>
Sat, 28 Apr 2007 13:15:21 +0000 (15:15 +0200)
(This used to be ctdb commit 9deaa1892faa8288cad9f6fde20d2aa8ba8af699)

ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c
ctdb/common/ctdb_daemon.c
ctdb/include/ctdb_private.h
ctdb/tools/ctdb_control.c

index 415d38b0fcee372b69e0c89908cc9f72396ed6e2..18685cd25e5d97a48d0b4c6fd80d305a2a5e4884 100644 (file)
@@ -897,7 +897,7 @@ int ctdb_setvnnmap(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_vnn
 }
 
 /*
-  ping a node
+  ping a node, return number of clients connected
  */
 int ctdb_ping(struct ctdb_context *ctdb, uint32_t destnode)
 {
@@ -907,10 +907,10 @@ int ctdb_ping(struct ctdb_context *ctdb, uint32_t destnode)
 
        ZERO_STRUCT(data);
        ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_PING, data, NULL, NULL, &res);
-       if (ret != 0 || res != 0) {
+       if (ret != 0) {
                return -1;
        }
-       return 0;
+       return res;
 }
 
 /*
index 83bac958e06ff9d0cab2696cc79219db99ea121f..731aadd5eac9bec913e653acebf6a4ba0272b56c 100644 (file)
@@ -176,7 +176,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 
        case CTDB_CONTROL_PING:
                CHECK_CONTROL_DATA_SIZE(0);
-               return 0;
+               return ctdb->num_clients;
 
        case CTDB_CONTROL_GETDBPATH: {
                uint32_t db_id;
index d305718575d6ded784ee591eeea158622769f59e..d0d2c1a46df77a187d6422b61611ec19028142e1 100644 (file)
@@ -232,6 +232,7 @@ static void daemon_request_connect_wait(struct ctdb_client *client,
 */
 static int ctdb_client_destructor(struct ctdb_client *client)
 {
+       client->ctdb->num_clients--;
        close(client->fd);
        client->fd = -1;
        return 0;
@@ -547,6 +548,7 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
        client = talloc_zero(ctdb, struct ctdb_client);
        client->ctdb = ctdb;
        client->fd = fd;
+       ctdb->num_clients++;
 
        client->queue = ctdb_queue_setup(ctdb, client, fd, CTDB_DS_ALIGNMENT, 
                                         ctdb_daemon_read_cb, client);
index dbbce30a447d82b39b8ef68d47dda5df2a90ed33..fa8d3debf469c4c2a597bb88523e5d49ac99092d 100644 (file)
@@ -195,6 +195,7 @@ struct ctdb_context {
        struct ctdb_daemon_data daemon;
        struct ctdb_status status;
        struct ctdb_vnn_map *vnn_map;
+       uint32_t num_clients;
 };
 
 struct ctdb_db_context {
index 6057a186f3db3fba32c0447e7451ef2940f0cd2a..41f6c4c774f50140054825dd54022a155d54ff2d 100644 (file)
@@ -261,11 +261,11 @@ static int control_ping(struct ctdb_context *ctdb, int argc, const char **argv)
        for (i=0;i<ctdb->num_nodes;i++) {
                struct timeval tv = timeval_current();
                ret = ctdb_ping(ctdb, i);
-               if (ret != 0) {
+               if (ret == -1) {
                        printf("Unable to get ping response from node %u\n", i);
                } else {
-                       printf("response from %u time=%.6f sec\n", 
-                              i, timeval_elapsed(&tv));
+                       printf("response from %u time=%.6f sec  (%d clients)\n", 
+                              i, timeval_elapsed(&tv), ret);
                }
        }
        return 0;