[mapserver-dev] Dynamicaly writing Mapfiles for WMS-Servers

Frank Warmerdam warmerdam at pobox.com
Fri Feb 12 15:40:21 EST 2010


Stephan Holl wrote:
> Hello mapserver users/devs,
> 
> we are developing an application which mainly displays charts and
> graphic plotts about scientific data (hydrologic measurment-data). Also
> vertical cross section through waterbodies can be produced. 
> 
> However, a WMS-component is needed and we are thinking about Mapserver.
> Therefor one mapfile will be used and our mechanism is able to add new
> layers to the mapfile depending on the workflow in the app. Does
> anybody have any experience with such a setup?
> 
> There are some questions open, perhaps you can give us some hints here:
> * What happens when the mapfile gets written and a WMS-request tries to
>   open/read the mapfile directly? It seems that there are no
>   flock-calls inside the mapserver-code for locking the mapfile.

Stephan,

I think the traditional unix approach to replacing a file atomically is
to write it to a temporary name in the same directory and then using the
rename() function.  The rename(2) man page mentioned that replacement of
the existing file is atomic.

This should be enough to ensure that any attempt to read the file by
mapserver would either get a consistent old or new version of the file
without risk of it being in the middle of being written.  For this very
reason unix keeps around old files that are open even if they have been
unlinked.

So, I don't think we need to worry about flock() to enable this sort
of (fairly common) scenario.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-dev mailing list