Index: /trunk/gsdl/src/colservr/browsefilter.cpp
===================================================================
--- /trunk/gsdl/src/colservr/browsefilter.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/browsefilter.cpp	(revision 13780)
@@ -304,4 +304,5 @@
   }
 
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   response.numDocs = numDocs;
   response.isApprox = Exact;
Index: /trunk/gsdl/src/colservr/gdbmsource.cpp
===================================================================
--- /trunk/gsdl/src/colservr/gdbmsource.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/gdbmsource.cpp	(revision 13780)
@@ -159,4 +159,5 @@
   infodbclass info;
   OIDout = gdbmptr->translate_OID (OIDin, info);
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   return true;
 }
@@ -314,4 +315,6 @@
     ++fields_here;
   }
+
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   return true;
 }
@@ -348,5 +351,8 @@
     translate_OID (OID, tOID, err, logout);
   infodbclass info;
-  if (!gdbmptr->getinfo(tOID, info)) return false;
+  if (!gdbmptr->getinfo(tOID, info)) {
+    gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
+    return false;
+  }
   
   if (info["hastxt"].getint() == 1) {
@@ -360,4 +366,6 @@
 				   defaultlanguage, collection, docnum, doc);
   }
+
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   return true;
 }
Index: /trunk/gsdl/src/colservr/lucenegdbmsource.cpp
===================================================================
--- /trunk/gsdl/src/colservr/lucenegdbmsource.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/lucenegdbmsource.cpp	(revision 13780)
@@ -68,6 +68,9 @@
     translate_OID (OID, tOID, err, logout);
   infodbclass info;
-  if (!gdbmptr->getinfo(tOID, info)) return false;
-  
+  if (!gdbmptr->getinfo(tOID, info)) {
+    gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
+    return false;
+  }
+
   if (info["hastxt"].getint() == 0) { // there is no text for this section
     return false; // true??
@@ -80,10 +83,14 @@
   
   // locate the parent info ingdbm db
-  if (!gdbmptr->getinfo(parent_OID, info)) return false;
-  
+  if (!gdbmptr->getinfo(parent_OID, info)) {
+    gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
+    return false;
+  }
+
   text_t archive_dir = info["assocfilepath"];
   text_t full_path_to_doc = filename_cat(collectdir, "index", "text", archive_dir, "doc.xml");
   
   doc.clear();
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   expat_document(full_path_to_doc, ((lucenesearchclass*)textsearchptr)->gdbm_level, text_t(docnum), doc);
   return true;
Index: /trunk/gsdl/src/colservr/lucenequeryfilter.cpp
===================================================================
--- /trunk/gsdl/src/colservr/lucenequeryfilter.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/lucenequeryfilter.cpp	(revision 13780)
@@ -261,4 +261,5 @@
   }
 
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   response.numDocs = queryresults.docs_matched;
   response.isApprox = queryresults.is_approx;
Index: /trunk/gsdl/src/colservr/mgppqueryfilter.cpp
===================================================================
--- /trunk/gsdl/src/colservr/mgppqueryfilter.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/mgppqueryfilter.cpp	(revision 13780)
@@ -250,4 +250,5 @@
   }
 
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   response.numDocs = queryresults.docs_matched;
   response.isApprox = queryresults.is_approx;
Index: /trunk/gsdl/src/colservr/mgppsearch.cpp
===================================================================
--- /trunk/gsdl/src/colservr/mgppsearch.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/mgppsearch.cpp	(revision 13780)
@@ -212,4 +212,5 @@
   }
   // clean up
+  unload_database();  // Important that local library doesn't leave any files open
   delete []indexname;
   return true;
@@ -270,7 +271,8 @@
     queryresult.terms.push_back(term);
     queryresult.orgterms.push_back(term);
-
-  }
+  }
+
   // clean up
+  unload_database();  // Important that local library doesn't leave any files open
   delete []indexname;
 
Index: /trunk/gsdl/src/colservr/mgqueryfilter.cpp
===================================================================
--- /trunk/gsdl/src/colservr/mgqueryfilter.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/mgqueryfilter.cpp	(revision 13780)
@@ -445,4 +445,5 @@
   }
 
+  gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
   response.numDocs = queryresults.docs_matched;
   response.isApprox = queryresults.is_approx;
Index: /trunk/gsdl/src/colservr/mgsearch.cpp
===================================================================
--- /trunk/gsdl/src/colservr/mgsearch.cpp	(revision 13779)
+++ /trunk/gsdl/src/colservr/mgsearch.cpp	(revision 13780)
@@ -336,4 +336,5 @@
     // retrieve the results
     getresults (queryparams, queryresults);
+    unload_database();  // Important that local library doesn't leave any files open
     return true;
   }
@@ -561,4 +562,5 @@
   }
 
+  unload_database();  // Important that local library doesn't leave any files open
   return (bool)databaseloaded;
 }
