static rstatus_t stats_pool_init(struct stats_pool *stp, struct server_pool *sp) { rstatus_t status; stp->name = sp->name; array_null(&stp->metric); array_null(&stp->server); status = stats_pool_metric_init(&stp->metric); if (status != NC_OK) { return status; } status = stats_server_map(&stp->server, &sp->server); if (status != NC_OK) { stats_metric_deinit(&stp->metric); return status; } log_debug(LOG_VVVERB, "init stats pool '%.*s' with %"PRIu32" metric and " "%"PRIu32" server", stp->name.len, stp->name.data, array_n(&stp->metric), array_n(&stp->metric)); return NC_OK; }
//把stats_pool_codec数组成员赋值给stats_pool->metric数组 //把stats_server_codec数组成员赋值给stats_pool->server数组中的相关成员 static rstatus_t stats_pool_init(struct stats_pool *stp, struct server_pool *sp) { rstatus_t status; stp->name = sp->name; array_null(&stp->metric); array_null(&stp->server); //把stats_pool_codec中的成员拷贝到stats_pool->metric status = stats_pool_metric_init(&stp->metric);//把stats_pool_codec数组成员赋值给stats_pool->metric数组 if (status != NC_OK) { return status; } //把stats_server_codec数组成员赋值给stats_pool->server数组中的相关成员 //大server中的server:配置列表有多少个,这里的stats_pool->server数组就有多少个成员 status = stats_server_map(&stp->server, &sp->server); //sp->server这个是配置文件中每个大server中对应的servers: if (status != NC_OK) { stats_metric_deinit(&stp->metric); return status; } log_debug(LOG_VVVERB, "init stats pool '%.*s' with %"PRIu32" metric and " "%"PRIu32" server", stp->name.len, stp->name.data, array_n(&stp->metric), array_n(&stp->metric)); return NC_OK; }