You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by David Reid <ab...@dial.pipex.com> on 1999/09/10 13:19:44 UTC
[PATCH] mod_mmap_static
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 */
};
Re: [PATCH] mod_mmap_static
Posted by David Reid <ab...@dial.pipex.com>.
Ben,
Thanks for the info. I'll look into it in more detail when I get back from
work after the weekend.
david
----- Original Message -----
From: Ben Laurie <be...@algroup.co.uk>
To: <ne...@apache.org>
Sent: 10 September 1999 16:27
Subject: Re: [PATCH] mod_mmap_static
> David Reid wrote:
> >
> > Ben,
> >
> > It won't work with HOOK_LAST as it needs the core to have got the
filename
> > before it runs.
>
> ?? The topological sort ensures that happens (tsort takes precedence
> over priority). Have you tested it? Coz if it doesn't work, its a bug.
>
> > But here's another possibility...how about having an
> > apr_run_translate_name_from(r, HOOK_??) so we could set the start point
for
> > the running of the hooks? That way mod_mmap_static could be HOOK_FIRST
and
> > could call the new command with HOOK_LAST and that would do what the 1.3
> > version did? Not sure if it would work or not but just a thought.
>
> Erk. Sounds like a ghastly hack. If the hook really needs to be split
> then we should explicitly split it.
>
> Cheers,
>
> Ben.
>
> --
> http://www.apache-ssl.org/ben.html
>
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
> - Indira Gandhi
Re: [PATCH] mod_mmap_static
Posted by Dean Gaudet <dg...@arctic.org>.
On Fri, 10 Sep 1999, Ben Laurie wrote:
> Erk. Sounds like a ghastly hack. If the hook really needs to be split
> then we should explicitly split it.
that's what i was wondering...
i'm hoping ralf pipes up somewhere along here and re-explains the 4
translation phases he wanted ages back for mod_rewrite.
Dean
Re: [PATCH] mod_mmap_static
Posted by Ben Laurie <be...@algroup.co.uk>.
David Reid wrote:
>
> Ben,
>
> It won't work with HOOK_LAST as it needs the core to have got the filename
> before it runs.
?? The topological sort ensures that happens (tsort takes precedence
over priority). Have you tested it? Coz if it doesn't work, its a bug.
> But here's another possibility...how about having an
> apr_run_translate_name_from(r, HOOK_??) so we could set the start point for
> the running of the hooks? That way mod_mmap_static could be HOOK_FIRST and
> could call the new command with HOOK_LAST and that would do what the 1.3
> version did? Not sure if it would work or not but just a thought.
Erk. Sounds like a ghastly hack. If the hook really needs to be split
then we should explicitly split it.
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
Re: [PATCH] mod_mmap_static
Posted by David Reid <ab...@dial.pipex.com>.
Ben,
It won't work with HOOK_LAST as it needs the core to have got the filename
before it runs. But here's another possibility...how about having an
apr_run_translate_name_from(r, HOOK_??) so we could set the start point for
the running of the hooks? That way mod_mmap_static could be HOOK_FIRST and
could call the new command with HOOK_LAST and that would do what the 1.3
version did? Not sure if it would work or not but just a thought.
david
----- Original Message -----
From: Ben Laurie <be...@algroup.co.uk>
To: <ne...@apache.org>
Sent: 10 September 1999 15:05
Subject: Re: [PATCH] mod_mmap_static
> David Reid wrote:
> >
> > 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.
>
> In theory, at least, HOOK_REALLY_LAST is reserved for the core code. You
> should use HOOK_LAST, I think.
>
> > Also updates the Makefile.tmpl to reomve alloc.h.
>
> I'm about to commit a dependencies update.
>
> Cheers,
>
> Ben.
>
> --
> http://www.apache-ssl.org/ben.html
>
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
> - Indira Gandhi
Re: [PATCH] mod_mmap_static
Posted by Ben Laurie <be...@algroup.co.uk>.
David Reid wrote:
>
> 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.
In theory, at least, HOOK_REALLY_LAST is reserved for the core code. You
should use HOOK_LAST, I think.
> Also updates the Makefile.tmpl to reomve alloc.h.
I'm about to commit a dependencies update.
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi