FAQs
Zeige die ganze FAQ Zum InhaltsverzeichnisMapScript
What is MapScript?
What is MapScript and what is it for?
Is MapServer Thread-safe?
Is MapServer Thread-safe?
Q: Is MapServer thread-safe?
A: Generally, no (but see the next question). Many components of MapServer use static or global data that could potentially be modified by another thread. Under heavy load these unlikely events become inevitable, and could result in sporadic errors.
Q: Is it possible to safely use any of MapServer in a multi-threaded application?
A: Some of it, yes, with care. Or with Python :) Programmers must either avoid using the unsafe components of MapServer or carefully place locks around them. Python's global interpreter lock immunizes against MapServer threading problems; since no mapscript code ever releases the GIL all mapscript functions or methods are effectively atomic. Users of mapscript and Java, .NET, mod_perl, or mod_php do not have this extra layer of protection.
A: Which components are to be avoided?
Q: Below are lists of unsafe and unprotected components and unsafe but locked components.
Unsafe:
- OGR layers: use unsafe CPL services
- Cartoline rendering: static data
- Imagemap output: static data
- SWF output: static data and use of unsafe msGetBasename()
- SVG output: static data
- WMS/WFS server: static data used for state of dispatcher
- Forcing a temporary file base (an obscure feature): static data
- MyGIS: some static data
Unsafe, but locked:
- Map config file loading: global parser
- Setting class and and layer filter expressions (global parser)
- Class expression evaluation (global parser)
- Setting map and layer projections (PROJ)
- Raster layer rendering and querying (GDAL)
- Database Connections (mappool.c)
- PostGIS support
- Oracle Spatial (use a single environment handle for connection)
- SDE support (global layer cache)
- Error handling (static repository of the error objects)
- WMS/WFS client connections: potential race condition in Curl initialization
- Plugin layers (static repository of the loaded dll-s)
Rather coarse locks are in place for the above. Only a single thread can use the global parser at a time, and only one thread can access GDAL raster data at a time. Performance is exchanged for safety.
Diese FAQ betrifft: MapServer 4.6, MapServer 4.8