]> granicus.if.org Git - apache/commitdiff
Added EnableMMAP directive to allow the server administrator to
authorBrian Pane <brianp@apache.org>
Sat, 11 May 2002 23:24:29 +0000 (23:24 +0000)
committerBrian Pane <brianp@apache.org>
Sat, 11 May 2002 23:24:29 +0000 (23:24 +0000)
prevent mmap of file buckets upon read.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95040 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/http_core.h
server/core.c

diff --git a/CHANGES b/CHANGES
index d6beba0950babb58037b6ba126945a2826551bba..3f3cc97c1853411765105314eb4fb08b310e9c62 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.37
 
+  *) Added EnableMMAP config directive to enable the server
+     administrator to disable memory-mapping of delivered files
+     on a per-directory basis.  [Brian Pane]
+
   *) Performance enhancements for mod_setenvif  [Brian Pane]
 
   *) Fix a mod_ssl build problem on OS/390.  [Jeff Trawick]
index 7bc555582e735cb02943c5a5378f572085949207..63a5cfe36e95851f0cf07cde2f42a8fade1ed1c0 100644 (file)
@@ -515,6 +515,15 @@ typedef struct {
     etag_components_t etag_bits;
     etag_components_t etag_add;
     etag_components_t etag_remove;
+
+    /*
+     * Run-time performance tuning
+     */
+#define ENABLE_MMAP_OFF    (0)
+#define ENABLE_MMAP_ON     (1)
+#define ENABLE_MMAP_UNSET  (2)
+    int enable_mmap;  /* whether files in this dir can be mmap'ed */
+
 } core_dir_config;
 
 /* Per-server core configuration */
index ff60706c2fd2c6ceee5f55b87837cd534944df4b..776420b706af3f13f96dfeb2729c9e6aeaef5445 100644 (file)
@@ -180,6 +180,8 @@ static void *create_core_dir_config(apr_pool_t *a, char *dir)
     conf->etag_add = ETAG_UNSET;
     conf->etag_remove = ETAG_UNSET;
 
+    conf->enable_mmap = ENABLE_MMAP_UNSET;
+
     return (void *)conf;
 }
 
@@ -441,6 +443,10 @@ static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
         conf->etag_bits &= (~ ETAG_NONE);
     }
 
+    if (new->enable_mmap != ENABLE_MMAP_UNSET) {
+        conf->enable_mmap = new->enable_mmap;
+    }
+
     return (void*)conf;
 }
 
@@ -1422,6 +1428,29 @@ static const char *set_etag_bits(cmd_parms *cmd, void *mconfig,
     return NULL;
 }
 
+static const char *set_enable_mmap(cmd_parms *cmd, void *d_,
+                                   const char *arg)
+{
+    core_dir_config *d = d_;
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
+
+    if (err != NULL) {
+        return err;
+    }
+
+    if (strcasecmp(arg, "on") == 0) {
+        d->enable_mmap = ENABLE_MMAP_ON;
+    }
+    else if (strcasecmp(arg, "off") == 0) {
+        d->enable_mmap = ENABLE_MMAP_OFF;
+    }
+    else {
+        return "parameter must be 'on' or 'off'";
+    }
+
+    return NULL;
+}
+
 static const char *satisfy(cmd_parms *cmd, void *c_, const char *arg)
 {
     core_dir_config *c = c_;
@@ -2871,6 +2900,8 @@ AP_INIT_TAKE1("DefaultType", ap_set_string_slot,
   OR_FILEINFO, "the default MIME type for untypable files"),
 AP_INIT_RAW_ARGS("FileETag", set_etag_bits, NULL, OR_FILEINFO,
   "Specify components used to construct a file's ETag"),
+AP_INIT_TAKE1("EnableMMAP", set_enable_mmap, NULL, OR_FILEINFO,
+  "Controls whether memory-mapping may be used to read files"),
 
 /* Old server config file commands */
 
@@ -3230,6 +3261,11 @@ static int default_handler(request_rec *r)
             e = apr_bucket_file_create(fd, 0, (apr_size_t)r->finfo.size,
                                        r->pool, c->bucket_alloc);
 
+#if APR_HAS_MMAP
+        if (d->enable_mmap == ENABLE_MMAP_OFF) {
+            (void)apr_bucket_file_enable_mmap(e, 0);
+        }
+#endif
         APR_BRIGADE_INSERT_TAIL(bb, e);
         e = apr_bucket_eos_create(c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(bb, e);