static int nntp_like_process_connection()

in c-modules/nntp_like/mod_nntp_like.c [115:155]


static int nntp_like_process_connection(conn_rec *c)
{
    apr_bucket_brigade *bb;
    apr_status_t rv;
    nntp_like_srv_cfg_t *cfg =
        ap_get_module_config(c->base_server->module_config,
                             &nntp_like_module);

    if (!cfg->enabled) {
        return DECLINED;
    }

    /* handshake if talking over SSL */
    if ((rv = nntp_like_init_connection(c)) != APR_SUCCESS) {
        return rv;
    }

    /* send the welcome message */
    if ((rv = nntp_like_send_welcome(c)) != APR_SUCCESS) {
        return rv;
    }

    do {
        bb = apr_brigade_create(c->pool, c->bucket_alloc);

        if ((rv = ap_get_brigade(c->input_filters, bb,
                                 AP_MODE_GETLINE,
                                 APR_BLOCK_READ, 0)) != APR_SUCCESS || 
             APR_BRIGADE_EMPTY(bb))
        {
            apr_brigade_destroy(bb);
            break;
        }

        APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create(c->bucket_alloc));

        rv = ap_pass_brigade(c->output_filters, bb);
    } while (rv == APR_SUCCESS);

    return OK;
}