summaryrefslogtreecommitdiffstats
path: root/ctdb/server
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-04-19 13:29:04 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-04-22 14:00:51 +1000
commit016522fe29ea6cbca989e87cde2e44793aa3e46b (patch)
treefa475e7c5edd859ebed25a22695ac2f3a94e638b /ctdb/server
parent34718078751754f1463dafc13a92062635baea27 (diff)
ctdbd: Set num_clients statistic from ctdb->num_clients
This fixes the problem of "ctdb statisticsreset" clearing the number of clients even when there are active clients. Values returned in statistics for frozen, recovering, memory_used are based on the current state of CTDB and are not maintained as statistics. This should include num_clients as well. Currently ctdb->num_clients is unused. So use that to track the number of clients and fill in statistics field only when requested. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit dc4ca816630ed44b419108da53421331243fb8c7)
Diffstat (limited to 'ctdb/server')
-rw-r--r--ctdb/server/ctdb_control.c3
-rw-r--r--ctdb/server/ctdb_daemon.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index 99b3dc4314..affb9dd00d 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -100,6 +100,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
int i;
CHECK_CONTROL_DATA_SIZE(0);
ctdb->statistics.memory_used = talloc_total_size(NULL);
+ ctdb->statistics.num_clients = ctdb->num_clients;
ctdb->statistics.frozen = 0;
for (i=1; i<= NUM_DB_PRIORITIES; i++) {
if (ctdb->freeze_mode[i] == CTDB_FREEZE_FROZEN) {
@@ -204,7 +205,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
case CTDB_CONTROL_PING:
CHECK_CONTROL_DATA_SIZE(0);
- return ctdb->statistics.num_clients;
+ return ctdb->num_clients;
case CTDB_CONTROL_SET_DB_READONLY: {
uint32_t db_id;
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index d2aae5a010..2bd9346010 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -245,7 +245,7 @@ static int ctdb_client_destructor(struct ctdb_client *client)
ctdb_takeover_client_destructor_hook(client);
ctdb_reqid_remove(client->ctdb, client->client_id);
- CTDB_DECREMENT_STAT(client->ctdb, num_clients);
+ client->ctdb->num_clients--;
if (client->num_persistent_updates != 0) {
DEBUG(DEBUG_ERR,(__location__ " Client disconnecting with %u persistent updates in flight. Starting recovery\n", client->num_persistent_updates));
@@ -974,7 +974,7 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
talloc_set_destructor(client, ctdb_client_destructor);
talloc_set_destructor(client_pid, ctdb_clientpid_destructor);
- CTDB_INCREMENT_STAT(ctdb, num_clients);
+ ctdb->num_clients++;
}