statsmc.c
int
sp_memcache_read_replies(backend_t *bep, struct stats_entries *stats)
{
    int err = 0;
    char buffer[MAXSTATSZ];
    int done = FALSE;
    int valid_stats_cnt = 0;
    struct sp_memcache_socket_state session_info;

    memset(&session_info, 0, sizeof session_info);
    gettimeofday(&session_info.start_time, NULL);
    session_info.timeout = session_info.time_remaining = bep->settings.read_ms;

    while(!done) {
        memset(buffer, 0, MAXSTATSZ);
        err = sp_memcache_read(bep, buffer, MAXSTATSZ,
                                     &session_info, &done);
        
        /* handle ECANCELED here! 
         */
        if (err == ECANCELED) {
            err = 0;
            goto bail;
        } else {
            bail_error(err);
        }

        err = sp_memcache_stats_add_stats(stats, buffer, &valid_stats_cnt);
        bail_error(err);

        /* if we complete a socket read and get no valid stats data out of
         * the buffer then we are obviously being fed crap data, so give up
         */
        if (valid_stats_cnt == 0) {
            done = TRUE;
        }
    }
 bail:
    bep->last_error = err;
    return err;
}
// parse data received from the server
parse data received from the server
parse data received from the server
int
sp_memcache_read_replies(backend_t *bep, struct stats_entries *stats)
{
    int err = 0;
    char buffer[MAXSTATSZ];
    int done = FALSE;
    int valid_stats_cnt = 0;
    struct sp_memcache_socket_state session_info;
    memset(&session_info, 0, sizeof session_info);
    gettimeofday(&session_info.start_time, NULL);
    session_info.timeout = session_info.time_remaining = bep->settings.read_ms;
    while(!done) {
        memset(buffer, 0, MAXSTATSZ);
        err = sp_memcache_read(bep, buffer, MAXSTATSZ,
                                     &session_info, &done);
        if (err == ECANCELED) {
            err = 0;
            goto bail;
        } else {
            bail_error(err);
        }
        err = sp_memcache_stats_add_stats(stats, buffer, &valid_stats_cnt);
        bail_error(err);
        if (valid_stats_cnt == 0) {
            done = TRUE;
        }
    }
 bail:
    bep->last_error = err;
    return err;
}
int sp_memcache_read_replies ( backend_t * bep , struct stats_entries * stats ) { int err = 0 ; char buffer [ MAXSTATSZ ] ; int done = FALSE ; int valid_stats_cnt = 0 ; struct sp_memcache_socket_state session_info ; memset ( & session_info , 0 , sizeof session_info ) ; gettimeofday ( & session_info . start_time , NULL ) ; session_info . timeout = session_info . time_remaining = bep -> settings . read_ms ; while ( ! done ) { memset ( buffer , 0 , MAXSTATSZ ) ; err = sp_memcache_read ( bep , buffer , MAXSTATSZ , & session_info , & done ) ; if ( err == ECANCELED ) { err = 0 ; goto bail ; } else { bail_error ( err ) ; } err = sp_memcache_stats_add_stats ( stats , buffer , & valid_stats_cnt ) ; bail_error ( err ) ; if ( valid_stats_cnt == 0 ) { done = TRUE ; } } bail : bep -> last_error = err ; return err ; }
parse data received from the server
parse data received from the server
/* handle ECANCELED here! 
         */ /* if we complete a socket read and get no valid stats data out of
         * the buffer then we are obviously being fed crap data, so give up
         */