[Avida-cvs] [avida-svn] r752 - in development: Avida.xcodeproj source/tools

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Thu Jun 15 18:18:48 PDT 2006


Author: brysonda
Date: 2006-06-15 21:18:48 -0400 (Thu, 15 Jun 2006)
New Revision: 752

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/tools/cTools.cc
Log:
Fix cTools::MkDir to properly close file handle after checking directory so that it no longer leaks file handles.

When printing dominant genotypes to the archive, MkDir gets called relatively frequently (under the new cDataFileManager scheme) and was chewing up the maximum open files.   At a frequency of 100 updates, this took over 100k updates and was not noticed.   With both Dominant and DominantParasite active, it happened around 50k updates and caused trouble.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-06-15 20:46:36 UTC (rev 751)
+++ development/Avida.xcodeproj/project.pbxproj	2006-06-16 01:18:48 UTC (rev 752)
@@ -943,7 +943,7 @@
 		DCC315CF076253A5008F7A48 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
 		DCC315D0076253A5008F7A48 /* task_event_gen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.cc; sourceTree = "<group>"; };
 		DCC315D1076253A5008F7A48 /* task_event_gen.old.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.old.cc; sourceTree = "<group>"; };
-		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
+		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */

Modified: development/source/tools/cTools.cc
===================================================================
--- development/source/tools/cTools.cc	2006-06-15 20:46:36 UTC (rev 751)
+++ development/source/tools/cTools.cc	2006-06-16 01:18:48 UTC (rev 752)
@@ -30,7 +30,7 @@
 {
   if (verbose) cout << "Checking for directory '" << dirname << "'..." << flush;
 
-  FILE * fp = fopen(dirname, "r");
+  FILE* fp = fopen(dirname, "r");
   if (fp == 0) {
     if (errno == ENOENT) {
       if (verbose) cout << "  not found, creating..." << flush;
@@ -47,6 +47,7 @@
     if (verbose) cout << "Warning: Failed to open '" << dirname << "'." << endl;
     return false;
   }
+  fclose(fp);
 
   if (verbose) cout << " found." << endl;
   return true;




More information about the Avida-cvs mailing list