MCPcopy Index your code
hub / github.com/MapServer/MapServer / msGDALCleanup

Function msGDALCleanup

mapgdal.c:71–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69/************************************************************************/
70
71void msGDALCleanup( void )
72
73{
74 if( bGDALInitialized )
75 {
76 int iRepeat = 5;
77 msAcquireLock( TLOCK_GDAL );
78
79#if GDAL_RELEASE_DATE > 20101207
80 {
81 /*
82 ** Cleanup any unreferenced but open datasets as will tend
83 ** to exist due to deferred close requests. We are careful
84 ** to only close one file at a time before refecting the
85 ** list as closing some datasets may cause others to be
86 ** closed (subdatasets in a VRT for instance).
87 */
88 GDALDatasetH *pahDSList = NULL;
89 int nDSCount = 0;
90 int bDidSomething;
91
92 do {
93 int i;
94 GDALGetOpenDatasets( &pahDSList, &nDSCount );
95 bDidSomething = FALSE;
96 for( i = 0; i < nDSCount && !bDidSomething; i++ )
97 {
98 if( GDALReferenceDataset( pahDSList[i] ) == 1 )
99 {
100 GDALClose( pahDSList[i] );
101 bDidSomething = TRUE;
102 }
103 else
104 GDALDereferenceDataset( pahDSList[i] );
105 }
106 } while( bDidSomething );
107 }
108#endif
109
110 while( iRepeat-- )
111 CPLPopErrorHandler();
112
113#if GDAL_RELEASE_DATE > 20021001
114 GDALDestroyDriverManager();
115#endif
116
117 msReleaseLock( TLOCK_GDAL );
118
119 bGDALInitialized = 0;
120 }
121}
122
123/************************************************************************/
124/* CleanVSIDir() */

Callers 1

msCleanupFunction · 0.85

Calls 2

msAcquireLockFunction · 0.85
msReleaseLockFunction · 0.85

Tested by

no test coverage detected