You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dirk-Willem van Gulik <di...@jrc.it> on 1999/04/21 18:42:25 UTC

Naughty ?

I know it says

 <STRONG>Note</STRONG>: don't bother asking for a for a <CODE>MMapDir</CODE>
  directive which
  recursively maps all the files in a directory.  Use Unix the way it was
  meant to be used.  For example, see the
  <A HREF="core.html#include">Include</A> directive, and consider this command:
  <PRE>
  find /www/htdocs -type f -print \
  | sed -e 's/.*/mmapfile &amp;/' &gt; /www/conf/mmap.conf
  </PRE>
 
But it is so useful. Anyone has a serious -1 (or a -2) against this. Even
if I put in strong wording into the manual ? Note that it just does a flat
directory. That is all.

And secondly; is this module really still that experimental. It does seem to
work fine on a range of systems, Solaris, Irix and FreeBSD. Under heavy load.

dw.

-------- Original Message --------
Date: Wed, 21 Apr 1999 18:38:53 +0200 (CEST)
From: Dirk-Willem van Gulik <di...@jrc.it>
To: dirk.vangulik@jrc.it

Index: mod_mmap_static.c
===================================================================
RCS file: /home/cvs//apache-1.3/src/modules/experimental/mod_mmap_static.c,v
retrieving revision 1.9
diff -u -c -3 -r1.9 mod_mmap_static.c
*** mod_mmap_static.c	1999/01/01 19:05:01	1.9
--- mod_mmap_static.c	1999/04/21 16:38:51
***************
*** 209,214 ****
--- 209,233 ----
      return NULL;
  }
  
+ static const char *mmapdir(cmd_parms *cmd, void *dummy, char * dirname)
+ {
+     DIR * d;
+     struct dirent * di;
+     const char * c;
+     /* lets not recurse.. noooo */
+     if ((d = opendir(dirname)) == NULL) {
+ 	ap_log_error(APLOG_MARK, APLOG_WARNING, cmd->server,
+ 	    "mmap_static: unable to opendir(%s), skipping", dirname);
+ 	return NULL;
+     }
+     for(;di = readdir(d);) 
+ 	if (di->d_type == DT_REG) 
+ 		c = mmapfile(cmd,dummy, ap_pstrcat(cmd->pool,dirname,"/",di->d_name,NULL));
+ 
+     closedir(d);
+     return NULL;
+ }
+ 
  static command_rec mmap_static_cmds[] =
  {
      {
***************
*** 216,221 ****
--- 235,244 ----
  	"A space separated list of files to mmap at config time"
      },
      {
+ 	"mmapdir", mmapdir, NULL, RSRC_CONF, ITERATE,
+ 	"A space separated list of directories in which to mmap at config time"
+     },
+     {
  	NULL
      }
  };
***************
*** 300,305 ****
--- 323,329 ----
  
      /* shortcircuit the get_path_info() stat() calls and stuff */
      r->finfo = match->finfo;
+ 
      return OK;
  }
  
***************
*** 363,369 ****
      }
      return OK;
  }
- 
  
  static const handler_rec mmap_static_handlers[] =
  {
--- 387,392 ----

Re: Naughty ?

Posted by Dean Gaudet <dg...@arctic.org>.

On Wed, 21 Apr 1999, Dirk-Willem van Gulik (kim) wrote:

> Dean Gaudet wrote:
>  
> > Ugh.  I give up on this fight against creeping featurism. 
> > Go ahead, reinvent unix.
> 
> Well, unix tries to be a general purpose OS.. rather than
> something which spews out a stream of TCP/http replies. Whilst
> optimizing the latter; you reivent the first. But then, in
> the workshop I used to work we had exacty 171 totally different
> nuts of a 12 mm diameter. And they where al useful for something.

Why do I suddenly have this urge to call you a perl weenie?  I know you're
not one of *them* ;)

> > As far as experimental notice this:
> > 
> >     res = core_module.translate_handler(r);
> > 
> 
> Yes. I know. A usefull but dirty thing. And hard to get around.

Any folks thinking about the API should look at why this is useful to
mod_mmap_static... to see if we can improve things.  The real difficulty
here is in the assumed mapping from url->filename -- abstracting that is a
nice fat juicy problem. 

Dean



Re: Naughty ?

Posted by "Dirk-Willem van Gulik (kim)" <di...@webweaving.org>.
Dean Gaudet wrote:
 
> Ugh.  I give up on this fight against creeping featurism. 
> Go ahead, reinvent unix.

Well, unix tries to be a general purpose OS.. rather than
something which spews out a stream of TCP/http replies. Whilst
optimizing the latter; you reivent the first. But then, in
the workshop I used to work we had exacty 171 totally different
nuts of a 12 mm diameter. And they where al useful for something.

> d_type is non-portable.

Ok. I'll rework this first.
 
> As far as experimental notice this:
> 
>     res = core_module.translate_handler(r);
> 

Yes. I know. A usefull but dirty thing. And hard to get around.

Dw

Re: Naughty ?

Posted by Dean Gaudet <dg...@arctic.org>.
Ugh.  I give up on this fight against creeping featurism.  Go ahead,
reinvent unix.

d_type is non-portable.

I love how freebsd man pages mention nothing of the standards.  How
completely nice for people to develop in a vacuum where it's impossible
to write portable programs.  At least Solaris and Linux man pages
tell you when you're using an extension.

I see d_type in glibc, but a small test program reveals it doesn't work on my
linux 2.0.x kernel.  Investigating the kernel sources I see that it's
not implemented (even in 2.2.x).  Gotta love those glibc folks.  I wonder
how much extra crud there is in glibc that just isn't implemented.

Ah, I see glibc defines _DIRENT_HAVE_D_TYPE, but freebsd doesn't.

Then this is probably a nice little portable test to see if you can
use d_type:

#if defined(DT_REG) && !defined(_DIRENT_HAVE_D_TYPE)

But... you should just modify mmapfile to have a "ignore but don't
fail" option ... since it already stat()s all the stuff provided
to it.

As far as experimental notice this:

    res = core_module.translate_handler(r);

That's not nice for a module to do.

Dean

On Wed, 21 Apr 1999, Dirk-Willem van Gulik wrote:

> I know it says
> 
>  <STRONG>Note</STRONG>: don't bother asking for a for a <CODE>MMapDir</CODE>
>   directive which
>   recursively maps all the files in a directory.  Use Unix the way it was
>   meant to be used.  For example, see the
>   <A HREF="core.html#include">Include</A> directive, and consider this command:
>   <PRE>
>   find /www/htdocs -type f -print \
>   | sed -e 's/.*/mmapfile &amp;/' &gt; /www/conf/mmap.conf
>   </PRE>
>  
> But it is so useful. Anyone has a serious -1 (or a -2) against this. Even
> if I put in strong wording into the manual ? Note that it just does a flat
> directory. That is all.
> 
> And secondly; is this module really still that experimental. It does seem to
> work fine on a range of systems, Solaris, Irix and FreeBSD. Under heavy load.
> 
> dw.
> 
> -------- Original Message --------
> Date: Wed, 21 Apr 1999 18:38:53 +0200 (CEST)
> From: Dirk-Willem van Gulik <di...@jrc.it>
> To: dirk.vangulik@jrc.it
> 
> Index: mod_mmap_static.c
> ===================================================================
> RCS file: /home/cvs//apache-1.3/src/modules/experimental/mod_mmap_static.c,v
> retrieving revision 1.9
> diff -u -c -3 -r1.9 mod_mmap_static.c
> *** mod_mmap_static.c	1999/01/01 19:05:01	1.9
> --- mod_mmap_static.c	1999/04/21 16:38:51
> ***************
> *** 209,214 ****
> --- 209,233 ----
>       return NULL;
>   }
>   
> + static const char *mmapdir(cmd_parms *cmd, void *dummy, char * dirname)
> + {
> +     DIR * d;
> +     struct dirent * di;
> +     const char * c;
> +     /* lets not recurse.. noooo */
> +     if ((d = opendir(dirname)) == NULL) {
> + 	ap_log_error(APLOG_MARK, APLOG_WARNING, cmd->server,
> + 	    "mmap_static: unable to opendir(%s), skipping", dirname);
> + 	return NULL;
> +     }
> +     for(;di = readdir(d);) 
> + 	if (di->d_type == DT_REG) 
> + 		c = mmapfile(cmd,dummy, ap_pstrcat(cmd->pool,dirname,"/",di->d_name,NULL));
> + 
> +     closedir(d);
> +     return NULL;
> + }
> + 
>   static command_rec mmap_static_cmds[] =
>   {
>       {
> ***************
> *** 216,221 ****
> --- 235,244 ----
>   	"A space separated list of files to mmap at config time"
>       },
>       {
> + 	"mmapdir", mmapdir, NULL, RSRC_CONF, ITERATE,
> + 	"A space separated list of directories in which to mmap at config time"
> +     },
> +     {
>   	NULL
>       }
>   };
> ***************
> *** 300,305 ****
> --- 323,329 ----
>   
>       /* shortcircuit the get_path_info() stat() calls and stuff */
>       r->finfo = match->finfo;
> + 
>       return OK;
>   }
>   
> ***************
> *** 363,369 ****
>       }
>       return OK;
>   }
> - 
>   
>   static const handler_rec mmap_static_handlers[] =
>   {
> --- 387,392 ----
>