[mapserver-users] Re: Hiding overviews

Eichner, Andreas - SID-NLK Andreas.Eichner at sid.sachsen.de
Mon Mar 31 09:52:29 EDT 2008


Hello Daniel,

before submitting a "patch" there are just some things to note. But it's
nice that there's so much interest on it.

> What was involved in setting up an Apache module? There was talk about

> doing that as an experiment a few weeks ago on the mapserver-dev list.

> If you are interested in sharing what you've done then I'm sure that 
> would generate some interest. Perhaps you could file a ticket and
attach 
> a patch and some notes?

Well, looked at the mail archive back till Jan 07 but could not find
something about it in a first quick look. Maybe you can point me to the
thread?
Currently I call the dirty thing mod_wms since that's what it currently
is. The main target was to get a faster WMS mainly because MapServer got
a little bit slow especially with large map files. I looked at the
mapserv.c and saw, that even in fastcgi mode it loads and parses the
hole map file for _every_ request. This seems to be a bad thing but
can't be done much different with CGI I think.
Well, if we would use the Apache module mechanism we can do it better.
We can load and parse the map file and ideally prepare everthing
required for the requests. When receiving a request we would do nearly
the same things that are currently done in the CGI - take the URI, break
it into name/value pairs, hash the things for fast lookups and take all
other things out of the already prepared MapObj.
This speeds up and simplifies much of the things but are only applicable
since we know that the configuration remains constant which is something
the CGI can't assume.
Currently the baby is mostly a hack... Some simple steps were involved
till now:
1. generate a template with: apxs2 -g -n wms
2. create a function taking the (currently) only config option we
provide which is taking the filename of the map file, try to load it as
usual with LoadMap() and store the result in a per directory config.
3. adopt the fastcgi output redirection code from mapio.c to redirect to
the Apache output functions
4. copy over most of the things from mapserv.c to the module's request
handler

Sounds easy, doesn't it? Well, there's a last step which makes it IMHO
being a real hack: the MapServer functions output the content type
directly to the output stream via things like
'msIO_printf("Content-type: text/xml%c%c",10,10);' which have to be
modified to set it in the Apache's request_rec.
So currently I can compile it under Debian Testing for Apache 2.2 and it
works quite well. Last week I've done a first successful build under
RedHat Enterprise Linux 5 with some additional packages from Fedora Core
(gdal, geos  f.e.) but had not much time for testing.
There are still some things to improve I believe but that would require
a deeper look into the source. Mainly this would involve a modification
of the cleanup code to prevent the destruction of label, font and symbol
caches. Also, in that environment it doesn't make much sense to close
database connections so we could keep them open from Apache startup to
shutdown and so would be nice to prepare the queries in the startup
sequence for faster handling at runtime...

Daniel, I would prefer to send a commented patch directly to you first
and let you decide what to do with it. Remember that I already missed
some things with the metadata thing... May be tried to improve the world
but really created the hell on earth ;-)

So that's for now. Will now comment the patch...

Greetings!


More information about the mapserver-users mailing list