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 */
conf->etag_add = ETAG_UNSET;
conf->etag_remove = ETAG_UNSET;
+ conf->enable_mmap = ENABLE_MMAP_UNSET;
+
return (void *)conf;
}
conf->etag_bits &= (~ ETAG_NONE);
}
+ if (new->enable_mmap != ENABLE_MMAP_UNSET) {
+ conf->enable_mmap = new->enable_mmap;
+ }
+
return (void*)conf;
}
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_;
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 */
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);