From: Bill Stoddard Date: Fri, 27 Jul 2001 19:58:15 +0000 (+0000) Subject: Replace ap_send_fd invocation with bucket brigade calls. Send an eos down X-Git-Tag: 2.0.23~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b114c5c37582ee85dcb3cf674a0a1736b6cc05b;p=thirdparty%2Fapache%2Fhttpd.git Replace ap_send_fd invocation with bucket brigade calls. Send an eos down the chain and let the brigade close the file descriptor when the network i/o is done. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89747 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/generators/mod_asis.c b/modules/generators/mod_asis.c index 39d9dc8d9aa..c5fcdc5042e 100644 --- a/modules/generators/mod_asis.c +++ b/modules/generators/mod_asis.c @@ -73,9 +73,8 @@ static int asis_handler(request_rec *r) { apr_file_t *f = NULL; - apr_status_t status; + apr_status_t rv; const char *location; - apr_size_t nbytes; if(strcmp(r->handler,ASIS_MAGIC_TYPE) && strcmp(r->handler,"send-as-is")) return DECLINED; @@ -89,9 +88,9 @@ static int asis_handler(request_rec *r) return HTTP_NOT_FOUND; } - if ((status = apr_file_open(&f, r->filename, APR_READ, + if ((rv = apr_file_open(&f, r->filename, APR_READ, APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "file permissions deny server access: %s", r->filename); return HTTP_FORBIDDEN; } @@ -118,20 +117,24 @@ static int asis_handler(request_rec *r) } if (!r->header_only) { - apr_off_t start = 0; - apr_off_t fsize = r->finfo.size; -#if APR_HAS_LARGE_FILES - /* must split into mutiple send_fd chunks */ - while (fsize > AP_MAX_SENDFILE) { - ap_send_fd(f, r, start, AP_MAX_SENDFILE, &nbytes); - start += AP_MAX_SENDFILE; - fsize -= AP_MAX_SENDFILE; + apr_bucket_brigade *bb; + apr_bucket *b; + + bb = apr_brigade_create(r->pool); + b = apr_bucket_file_create(f, 0, (apr_size_t) r->finfo.size, r->pool); + APR_BRIGADE_INSERT_TAIL(bb, b); + b = apr_bucket_eos_create(); + APR_BRIGADE_INSERT_TAIL(bb, b); + rv = ap_pass_brigade(r->output_filters, bb); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "mod_asis: ap_pass_brigade failed for file %s", r->filename); } -#endif - ap_send_fd(f, r, start, (apr_size_t)fsize, &nbytes); + } + else { + apr_file_close(f); } - apr_file_close(f); return OK; }