You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jw...@apache.org on 2001/06/27 22:18:11 UTC
cvs commit: httpd-2.0/server core.c protocol.c
jwoolley 01/06/27 13:18:11
Modified: . CHANGES
modules/arch/win32 mod_isapi.c
modules/cache mod_file_cache.c
modules/experimental mod_disk_cache.c
server core.c protocol.c
Log:
*) Account for the new pool parameter to apr_bucket_file_create()
and apr_bucket_file_make().
*) Simplify mod_file_cache's sendfile_handler by taking advantage
the new ability of file buckets to handle files opened in XTHREAD
mode. [Also inlined some of the brigade construction stuff in
mod_file_cache's handlers to save a palloc() or two.]
Revision Changes Path
1.231 +4 -1 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -d -u -r1.230 -r1.231
--- CHANGES 2001/06/26 17:40:54 1.230
+++ CHANGES 2001/06/27 20:17:56 1.231
@@ -1,10 +1,13 @@
Changes with Apache 2.0.19-dev
+ *) mod_file_cache is now more robust to filtering and serves requests
+ slightly more efficiently. [Cliff Woolley]
+
*) Fix problem handling FLUSH bucket in the chunked encoding filter.
Module was calling ap_rwrite() followed by ap_rflush() but the
served content was not being displayed in the browser. Inspection
of the output stream revealed that the first data chunk was
- missing the trailing CRLF required by the RFC.
+ missing the trailing CRLF required by the RFC. [Bill Stoddard]
*) apxs no longer generates ap_send_http_header() in the example handler
1.44 +1 -1 httpd-2.0/modules/arch/win32/mod_isapi.c
Index: mod_isapi.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/arch/win32/mod_isapi.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -u -r1.43 -r1.44
--- mod_isapi.c 2001/05/18 17:26:22 1.43
+++ mod_isapi.c 2001/06/27 20:18:00 1.44
@@ -944,7 +944,7 @@
}
b = apr_bucket_file_create(fd, (apr_off_t)tf->Offset,
- (apr_size_t)tf->BytesToWrite);
+ (apr_size_t)tf->BytesToWrite, r->pool);
APR_BRIGADE_INSERT_TAIL(bb, b);
if (tf->pTail && (apr_size_t)tf->TailLength) {
1.56 +22 -39 httpd-2.0/modules/cache/mod_file_cache.c
Index: mod_file_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/cache/mod_file_cache.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -u -r1.55 -r1.56
--- mod_file_cache.c 2001/06/18 05:39:10 1.55
+++ mod_file_cache.c 2001/06/27 20:18:03 1.56
@@ -115,6 +115,7 @@
#include "apr_mmap.h"
#include "apr_strings.h"
#include "apr_hash.h"
+#include "apr_buckets.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
@@ -206,7 +207,8 @@
return;
}
- rc = apr_file_open(&fd, fspec, APR_READ | APR_XTHREAD, APR_OS_DEFAULT, cmd->pool);
+ rc = apr_file_open(&fd, fspec, APR_READ | APR_BINARY | APR_XTHREAD,
+ APR_OS_DEFAULT, cmd->pool);
if (rc != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, rc, cmd->server,
"mod_file_cache: unable to open(%s, O_RDONLY), skipping", fspec);
@@ -318,7 +320,16 @@
static int mmap_handler(request_rec *r, a_file *file)
{
#if APR_HAS_MMAP
- ap_send_mmap (file->mm, r, 0, file->finfo.size);
+ apr_bucket *b;
+ apr_bucket_brigade *bb = apr_brigade_create(r->pool);
+
+ b = apr_bucket_mmap_create(file->mm, 0, file->finfo.size);
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ b = apr_bucket_eos_create();
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+
+ if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
+ return HTTP_INTERNAL_SERVER_ERROR;
#endif
return OK;
}
@@ -326,44 +337,16 @@
static int sendfile_handler(request_rec *r, a_file *file)
{
#if APR_HAS_SENDFILE
- apr_size_t nbytes;
- apr_status_t rv = APR_EINIT;
- apr_file_t *rfile;
- apr_os_file_t fd;
+ apr_bucket *b;
+ apr_bucket_brigade *bb = apr_brigade_create(r->pool);
- /* A cached file handle (more importantly, its file pointer) is
- * shared by all threads in the process. The file pointer will
- * be corrupted if multiple threads attempt to read from the
- * cached file handle. The sendfile API does not rely on the position
- * of the file pointer instead taking explicit file offset and
- * length arguments.
- *
- * We should call ap_send_fd with a cached file handle IFF
- * we are CERTAIN the file will be served with apr_sendfile().
- * The presense of an AP_FTYPE_FILTER in the filter chain nearly
- * guarantees that apr_sendfile will NOT be used to send the file.
- * Furthermore, AP_FTYPE_CONTENT filters will be at the beginning
- * of the chain, so it should suffice to just check the first
- * filter in the chain. If the first filter is not a content filter,
- * assume apr_sendfile() will be used to send the content.
- */
- if (r->output_filters && r->output_filters->frec) {
- if (r->output_filters->frec->ftype == AP_FTYPE_CONTENT)
- return DECLINED;
- }
+ b = apr_bucket_file_create(file->file, 0, file->finfo.size, r->pool);
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ b = apr_bucket_eos_create();
+ APR_BRIGADE_INSERT_TAIL(bb, b);
- /* Create an apr_file_t anchored out of the request pool to use
- * on the call to ap_send_fd(). The cached apr_file_t is allocated
- * out of pconf (a life of the server pool) and sending it down
- * the filter chain could cause memory leaks.
- */
- apr_os_file_get(&fd, file->file);
- apr_os_file_put(&rfile, &fd, r->pool);
- rv = ap_send_fd(rfile, r, 0, file->finfo.size, &nbytes);
- if (rv != APR_SUCCESS) {
- /* ap_send_fd will log the error */
+ if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
return HTTP_INTERNAL_SERVER_ERROR;
- }
#endif
return OK;
}
1.8 +1 -1 httpd-2.0/modules/experimental/mod_disk_cache.c
Index: mod_disk_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_disk_cache.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -u -r1.7 -r1.8
--- mod_disk_cache.c 2001/03/02 21:36:14 1.7
+++ mod_disk_cache.c 2001/06/27 20:18:05 1.8
@@ -98,7 +98,7 @@
}
}
- e = apr_bucket_file_create(fd, offset, r->finfo.size);
+ e = apr_bucket_file_create(fd, offset, r->finfo.size, r->pool);
APR_BRIGADE_INSERT_HEAD(bb, e);
e = apr_bucket_eos_create();
1.23 +1 -1 httpd-2.0/server/core.c
Index: core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -u -r1.22 -r1.23
--- core.c 2001/06/18 12:38:17 1.22
+++ core.c 2001/06/27 20:18:08 1.23
@@ -2996,7 +2996,7 @@
}
bb = apr_brigade_create(r->pool);
- e = apr_bucket_file_create(fd, 0, r->finfo.size);
+ e = apr_bucket_file_create(fd, 0, r->finfo.size, r->pool);
APR_BRIGADE_INSERT_HEAD(bb, e);
e = apr_bucket_eos_create();
1.28 +1 -1 httpd-2.0/server/protocol.c
Index: protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -u -r1.27 -r1.28
--- protocol.c 2001/06/14 22:56:12 1.27
+++ protocol.c 2001/06/27 20:18:09 1.28
@@ -938,7 +938,7 @@
apr_status_t rv;
bb = apr_brigade_create(r->pool);
- b = apr_bucket_file_create(fd, offset, len);
+ b = apr_bucket_file_create(fd, offset, len, r->pool);
APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(r->output_filters, bb);