Beispiel #1
0
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c) {
    bool ret = true;

    // removed by Bin
    // readded by UD
    
    if (add_stats != NULL) {
        if (!stat_type) {
            /* prepare general statistics for the engine */
            STATS_LOCK();
            append_stat("curr_bytes", add_stats, c, "%llu", (unsigned long long)stats.curr_bytes);
            append_stat("curr_items", add_stats, c, "%u", stats.curr_items);
            append_stat("total_items", add_stats, c, "%u", stats.total_items);
            append_stat("num_displacements", add_stats, c, "%u", stats.num_displacements);
            STATS_UNLOCK();
        } else {
            ret = false;
        }
    }

    return ret;
}
Beispiel #2
0
static yrmcds_error
parse_statistics(yrmcds_cnt* c, const yrmcds_cnt_response* r) {
    yrmcds_cnt_statistics* s = &c->stats;
    s->count = 0;

    const char* p = r->body;
    const char* end = r->body + r->body_length;
    while( p < end ) {
        if( p + 4 > end )
            return YRMCDS_PROTOCOL_ERROR;
        uint16_t name_len = ntoh16(p);
        uint16_t value_len = ntoh16(p + 2);
        if( p + 4 + name_len + value_len > end )
            return YRMCDS_PROTOCOL_ERROR;
        yrmcds_error err =
            append_stat(s, name_len, value_len, p + 4, p + 4 + name_len);
        if( err != YRMCDS_OK )
            return err;
        p += 4 + name_len + value_len;
    }
    return YRMCDS_OK;
}