if (offset) { len -= offset; }
apr_status_t mpxs_Apache__RequestRec_sendfile(pTHX_ request_rec *r,                                              const char *filename,                                              apr_off_t offset,                                              apr_size_t len){    apr_size_t nbytes;    apr_status_t rc;    apr_file_t *fp;    rc = apr_file_open(&fp, filename, APR_READ|APR_BINARY,                       APR_OS_DEFAULT, r->pool);    if (rc != APR_SUCCESS) {        if (GIMME_V == G_VOID) {            modperl_croak(aTHX_ rc, "Apache::RequestIO::sendfile");        }        else {            return rc;        }    }    if (!len) {        apr_finfo_t finfo;        apr_file_info_get(&finfo, APR_FINFO_NORM, fp);        len = finfo.size;    }    /* flush any buffered modperl output */    {        modperl_config_req_t *rcfg = modperl_config_req_get(r);                MP_CHECK_WBUCKET_INIT("$r->rflush");        if (rcfg->wbucket->outcnt) {            MP_TRACE_o(MP_FUNC, "flushing %d bytes [%s]",                       rcfg->wbucket->outcnt,                       apr_pstrmemdup(rcfg->wbucket->pool,                                      rcfg->wbucket->outbuf,                                      rcfg->wbucket->outcnt));            MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, TRUE),                         "Apache::RequestIO::sendfile");        }    }        rc = ap_send_fd(fp, r, offset, len, &nbytes);    /* apr_file_close(fp); */ /* do not do this */    if (GIMME_V == G_VOID && rc != APR_SUCCESS) {        modperl_croak(aTHX_ rc, "Apache::RequestIO::sendfile");    }    return rc;}