static void close_connection()

in wb/wb.c [2507:2557]


static void close_connection(struct connection * c)
{
    if ((c->read == 0 && c->keepalive) || (c->rwrote == 0)) {
        /*
         * server has legitimately shut down an idle keep alive request
         */
        if (good)
            good--;     /* connection never happened */
    }
    else {
        if (good == 1) {
            /* first time here */
            doclen = c->bread;
        }
        else if ((c->bread != doclen) && !nolength) {
            bad++;
            err_length++;
        }
        /* save out time */
        if (done < requests) {
#ifdef _WAF_BENCH_ // make sure not exceeding stats size
           struct data *s = &stats[(done++)%g_stats_window]; 
#else // original code goes here
            struct data *s = &stats[done++];
#endif //_WAF_BENCH_ // // make sure not exceeding stats size
            c->done      = lasttime = apr_time_now();
            s->starttime = c->start;
            s->ctime     = ap_max(0, c->connect - c->start);
            s->time      = ap_max(0, c->done - c->start);
            s->waittime  = ap_max(0, c->beginread - c->endwrite);
            if (heartbeatres && !(done % heartbeatres)) {
                fprintf(stderr, "Completed %d requests\n", done);
                fflush(stderr);
            }
        }
    }

    set_conn_state(c, STATE_UNCONNECTED);
#ifdef USE_SSL
    if (c->ssl) {
        SSL_shutdown(c->ssl);
        SSL_free(c->ssl);
        c->ssl = NULL;
    }
#endif
    apr_socket_close(c->aprsock);

    /* connect again */
    start_connect(c);
    return;
}