Take 2: Patch for ticket 2596 (Constant crashes under high load/many concurrent requests)
Attached is a revised patch (2596_v4.patch) to address server stability issues reported on ticket 2596.
The main culprit is an improperly scoped Ptr<MgResourceLayerDefinitionCacheItem>, which combined with a refcount restriction in the cache itself (similar to the restriction for cached spatial context readers), could cause MdfModel::VectorLayerDefinition pointers to be prematurely deleted under high load.
The patch also ensures the scale setting code is only applied to VectorLayerDefinition pointers that didn't come from the 2nd level cache.
This patch also removes the use of CLocalizer in the geos library, which as reported by Andreas Morf, has been shown to cause additional instability due to its use of std::setlocale (which isn't thread safe). Since the mgserver already forces a "C" locale for numbers (LC_NUMERIC) on startup, the use of CLocalizer in geos would be redundant.