}
/*
- ping a node
+ ping a node, return number of clients connected
*/
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;
}
/*
case CTDB_CONTROL_PING:
CHECK_CONTROL_DATA_SIZE(0);
- return 0;
+ return ctdb->num_clients;
case CTDB_CONTROL_GETDBPATH: {
uint32_t db_id;
*/
static int ctdb_client_destructor(struct ctdb_client *client)
{
+ client->ctdb->num_clients--;
close(client->fd);
client->fd = -1;
return 0;
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);
struct ctdb_daemon_data daemon;
struct ctdb_status status;
struct ctdb_vnn_map *vnn_map;
+ uint32_t num_clients;
};
struct ctdb_db_context {
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;