[mapserver-commits] r8772 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Mar 10 16:04:31 EDT 2009


Author: warmerdam
Date: 2009-03-10 16:04:31 -0400 (Tue, 10 Mar 2009)
New Revision: 8772

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapraster.c
Log:
support deferred close for GDAL files (#2815)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-03-10 17:03:06 UTC (rev 8771)
+++ trunk/mapserver/HISTORY.TXT	2009-03-10 20:04:31 UTC (rev 8772)
@@ -11,6 +11,9 @@
 
 Current Version (SVN trunk):
 ----------------------------
+
+- mapraster.c: use GDALOpenShared(), and CLOSE_CONNECTION=DEFERRED (#2815)
+
 - AGG font outline method change (#1243)
 
 - Change mapbit.c bitmask type from char to new 32bit ms_bitarray (#2930)

Modified: trunk/mapserver/mapraster.c
===================================================================
--- trunk/mapserver/mapraster.c	2009-03-10 17:03:06 UTC (rev 8771)
+++ trunk/mapserver/mapraster.c	2009-03-10 20:04:31 UTC (rev 8772)
@@ -1495,10 +1495,11 @@
       msGDALInitialize();
 
       msAcquireLock( TLOCK_GDAL );
-      hDS = GDALOpen(szPath, GA_ReadOnly );
+      hDS = GDALOpenShared(szPath, GA_ReadOnly );
 
       if(hDS != NULL) {
-        double	adfGeoTransform[6];
+          double	adfGeoTransform[6];
+          const char *close_connection;
 
             if (layer->projection.numargs > 0 && 
                 EQUAL(layer->projection.args[0], "auto"))
@@ -1573,7 +1574,23 @@
                 break;
             }
 
-            GDALClose( hDS );
+            close_connection = msLayerGetProcessingKey( layer, 
+                                                        "CLOSE_CONNECTION" );
+            
+            /* default to keeping open for single data files, and 
+               to closing for tile indexes */
+            if( close_connection == NULL && layer->tileindex == NULL )
+                close_connection = "DEFER";
+
+            if( close_connection != NULL
+                && strcasecmp(close_connection,"DEFER") == 0 )
+            {
+                GDALDereferenceDataset( hDS );
+            }
+            else
+            {
+                GDALClose( hDS );
+            }
             msReleaseLock( TLOCK_GDAL );
             continue;
         }



More information about the mapserver-commits mailing list