httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Reid" <ab...@dial.pipex.com>
Subject [PATCH] mod_mmap_static
Date Fri, 10 Sep 1999 11:19:44 GMT
Here is the promised patch for mod_mmap_static.c in the -2.0 branch.  It
compiles cleanly on FreeBSD 3.2 but as Apache won't currently build totally
I was unable to get it tested.  The beos version I have is almost identical
and works fine.

Also updates the Makefile.tmpl to reomve alloc.h.

david

============================================================================
=================
diff -ru apache-2.0/src/modules/experimental/Makefile.tmpl
apache-2.0-working/src/modules/experimental/Makefile.tmpl
--- apache-2.0/src/modules/experimental/Makefile.tmpl Thu Sep  2 02:19:39
1999
+++ apache-2.0-working/src/modules/experimental/Makefile.tmpl Fri Sep 10
12:15:33 1999
@@ -7,8 +7,17 @@
 mod_mmap_static.o: mod_mmap_static.c $(INCDIR)/httpd.h \
  $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
  $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
- $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h \
- $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
+ $(OSDIR)/os-inline.c $(INCDIR)/ap_ctype.h \
+ $(INCDIR)/hsregex.h ../../lib/apr/include/apr_general.h \
+ ../../lib/apr/include/apr_config.h ../../lib/apr/include/apr_errno.h \
+ ../../lib/apr/include/apr_lib.h ../../lib/apr/include/apr_file_io.h \
+ ../../lib/apr/include/hsregex.h $(INCDIR)/buff.h \
+ $(INCDIR)/ap_iol.h $(INCDIR)/ap.h $(INCDIR)/apr.h \
  $(INCDIR)/util_uri.h $(INCDIR)/http_config.h \
- $(INCDIR)/http_log.h $(INCDIR)/http_protocol.h \
+ $(INCDIR)/ap_hooks.h $(INCDIR)/http_log.h \
+ $(INCDIR)/http_protocol.h ../../lib/apr/include/apr_portable.h \
+ ../../lib/apr/include/apr_thread_proc.h \
+ ../../lib/apr/include/apr_win.h \
+ ../../lib/apr/include/apr_network_io.h \
+ ../../lib/apr/include/apr_lock.h ../../lib/apr/include/apr_time.h \
  $(INCDIR)/http_request.h $(INCDIR)/http_core.h
diff -ru apache-2.0/src/modules/experimental/mod_mmap_static.c
apache-2.0-working/src/modules/experimental/mod_mmap_static.c
--- apache-2.0/src/modules/experimental/mod_mmap_static.c Wed Sep  1
02:20:19 1999
+++ apache-2.0-working/src/modules/experimental/mod_mmap_static.c Fri Sep 10
12:11:30 1999
@@ -145,7 +145,7 @@
     return sconf;
 }

-static void cleanup_mmap(void *sconfv)
+ap_status_t cleanup_mmap(void *sconfv)
 {
     a_server_config *sconf = sconfv;
     size_t n;
@@ -158,6 +158,7 @@
  ++file;
  --n;
     }
+    return APR_SUCCESS;
 }

 static const char *mmapfile(cmd_parms *cmd, void *dummy, char *filename)
@@ -206,17 +207,6 @@
     return NULL;
 }

-static command_rec mmap_static_cmds[] =
-{
-    {
- "mmapfile", mmapfile, NULL, RSRC_CONF, ITERATE,
- "A space separated list of files to mmap at config time"
-    },
-    {
- NULL
-    }
-};
-
 static int file_compare(const void *av, const void *bv)
 {
     const a_file *a = av;
@@ -238,7 +228,8 @@
     return c;
 }

-static void mmap_init(server_rec *s, ap_context_t *p)
+static void mmap_post_config(ap_context_t *p, ap_context_t *plog,
+    ap_context_t *ptemp, server_rec *s)
 {
     a_server_config *sconf;
     ap_array_header_t *inodes;
@@ -275,25 +266,27 @@
     a_server_config *sconf;
     a_file tmp;
     a_file *match;
-    int res;

     sconf = ap_get_module_config(r->server->module_config,
&mmap_static_module);

     /* we only operate when at least one mmapfile directive was used */
     if (ap_is_empty_table(sconf->files))
- return DECLINED;
+     return DECLINED;

     /* we require other modules to first set up a filename */
+    /* with the hooks we no longer need to do this as we're going to be
+     * the last translate_handler that's called
     res = core_module.translate_handler(r);
-    if (res == DECLINED || !r->filename) {
- return res;
-    }
+     */
+    if (!r->filename)
+     return DECLINED;
+
     tmp.filename = r->filename;
     match = (a_file *)bsearch(&tmp, sconf->files->elts,
sconf->files->nelts,
  sizeof(a_file), file_compare);
-    if (match == NULL) {
- return DECLINED;
-    }
+    if (match == NULL)
+     return DECLINED;
+

     /* shortcircuit the get_path_info() stat() calls and stuff */
     r->finfo = match->finfo;
@@ -361,32 +354,34 @@
     return OK;
 }

+static command_rec mmap_cmds[] =
+{
+    {"mmapfile", mmapfile, NULL, RSRC_CONF, ITERATE,
+ "A space separated list of files to mmap at config time"},
+    {NULL}
+};
+
+static void register_hooks(void)
+{
+    static const char * const aszPre[]={ "http_core.c",NULL };
+    ap_hook_post_config(mmap_post_config,NULL,NULL,HOOK_MIDDLE);
+    ap_hook_translate_name(mmap_static_xlat,aszPre,NULL,HOOK_REALLY_LAST);
+};

-static const handler_rec mmap_static_handlers[] =
+static const handler_rec mmap_handlers[] =
 {
-    { "*/*", mmap_static_handler },
-    { NULL }
+    {"*/*", mmap_static_handler},
+    {NULL}
 };

 module MODULE_VAR_EXPORT mmap_static_module =
 {
-    STANDARD_MODULE_STUFF,
-    mmap_init,   /* initializer */
-    NULL,   /* dir config creater */
-    NULL,   /* dir merger --- default is to override */
-    create_server_config, /* server config */
-    NULL,   /* merge server config */
-    mmap_static_cmds,  /* command handlers */
-    mmap_static_handlers, /* handlers */
-    mmap_static_xlat,  /* filename translation */
-    NULL,   /* check_user_id */
-    NULL,   /* check auth */
-    NULL,   /* check access */
-    NULL,   /* type_checker */
-    NULL,   /* fixups */
-    NULL,   /* logger */
-    NULL,   /* header parser */
-    NULL,   /* child_init */
-    NULL,   /* child_exit */
-    NULL   /* post read-request */
+    STANDARD20_MODULE_STUFF,
+    NULL,           /* create per-directory config structures */
+    NULL,           /* merge per-directory config structures  */
+    create_server_config, /* create per-server config structures    */
+    NULL,           /* merge per-server config structures     */
+    mmap_cmds,          /* command handlers */
+    mmap_handlers,         /* handlers */
+    register_hooks      /* register hooks */
 };



Mime
View raw message