void stats_destroy(struct stats *st) { stats_stop_aggregator(st); stats_pool_unmap(&st->sum); stats_pool_unmap(&st->shadow); stats_pool_unmap(&st->current); stats_destroy_buf(st); nc_free(st); }
rstatus_t stats_reset_and_recover(struct context *ctx, struct stats_pool *stp_src, struct hash_table **sit) { rstatus_t status; struct stats *st; struct array *server_pool; st = ctx->stats; server_pool = &ctx->pool; stats_stop_aggregator(st); stats_pool_unmap(&st->sum); stats_pool_unmap(&st->shadow); stats_pool_unmap(&st->current); stats_destroy_buf(st); st->updated = 0; st->aggregate = 0; /* map server pool to current (a), shadow (b) and sum (c) */ status = stats_pool_map(&st->current, server_pool); if (status != NC_OK) { return NC_ERROR; } status = stats_pool_map(&st->shadow, server_pool); if (status != NC_OK) { return NC_ERROR; } status = stats_pool_map(&st->sum, server_pool); if (status != NC_OK) { return NC_ERROR; } status = stats_create_buf(st); if (status != NC_OK) { return NC_ERROR; } status = stats_pool_copy_recover(ctx, stp_src, sit); if (status != NC_OK) { return NC_ERROR; } status = stats_start_aggregator(st); if (status != NC_OK) { return NC_ERROR; } return NC_OK; }