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)
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) {
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;
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));
talloc_set_destructor(client, ctdb_client_destructor);
talloc_set_destructor(client_pid, ctdb_clientpid_destructor);
- CTDB_INCREMENT_STAT(ctdb, num_clients);
+ ctdb->num_clients++;
}