File Descriptor Leak and Patch
Steve Wormley
steve at WORMLEY.COM
Sat Jul 9 15:31:33 EDT 2005
I had a minor issue where I loaded a new(large) tiled dataset into mapserver
(using PHP/Mapscript to view) and after a few iterations the web server ran
out of file descriptors.
I don't claim to understand how the code works, but the attached patch
appears to have fixed most of the issue.
-Steve Wormley
diff -ur orig/mapserver-4.6.0/mapshape.c mapserver-4.6.0/mapshape.c
--- orig/mapserver-4.6.0/mapshape.c 2005-06-14 09:03:34.000000000 -0700
+++ mapserver-4.6.0/mapshape.c 2005-07-09 00:36:27.000000000 -0700
@@ -1715,6 +1715,7 @@
if(strlen(filename) == 0) continue; /* check again */
/* open the shapefile */
+ msSHPCloseFile(tSHP->shpfile);
#ifndef IGNORE_MISSING_DATA
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1)
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1)
@@ -1785,6 +1786,7 @@
if(strlen(filename) == 0) continue; /* check again */
/* open the shapefile */
+ msSHPCloseFile(tSHP->shpfile);
#ifndef IGNORE_MISSING_DATA
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1)
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1)
@@ -1824,6 +1826,7 @@
if(strlen(filename) == 0) continue; /* check again */
/* open the shapefile */
+ msSHPCloseFile(tSHP->shpfile);
#ifndef IGNORE_MISSING_DATA
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1)
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1)
@@ -1897,6 +1900,7 @@
/* open the shapefile, since a specific tile was request an error should be generated if that tile does not exist */
if(strlen(filename) == 0) return(MS_FAILURE);
+ msSHPCloseFile(tSHP->shpfile);
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1)
if(msSHPOpenFile(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1)
return(MS_FAILURE);
More information about the mapserver-dev
mailing list