Index: trunk/psLib/src/db/psDB.c
===================================================================
--- trunk/psLib/src/db/psDB.c	(revision 16695)
+++ trunk/psLib/src/db/psDB.c	(revision 16696)
@@ -23,5 +23,5 @@
  * 4.1.2 or newer is required.
  *
- * $Id: psDB.c,v 1.150 2008-02-28 02:02:47 jhoblitt Exp $
+ * $Id: psDB.c,v 1.151 2008-02-28 02:13:03 jhoblitt Exp $
  */
 
@@ -80,5 +80,5 @@
 
 // cache of prepared query statements
-// static pthread_mutex_t preparedQueryMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t preparedQueryMutex = PTHREAD_MUTEX_INITIALIZER;
 static psHash *preparedQuery = NULL;
 
@@ -857,11 +857,12 @@
 
     // start lock on query cache
-//    if (psMemGetThreadSafety()) {
-//        pthread_mutex_lock(&preparedQueryMutex);
-//    }
+    if (psMemGetThreadSafety()) {
+        pthread_mutex_lock(&preparedQueryMutex);
+    }
 
     // initalize the prepared query cache
     if (!preparedQuery) {
         preparedQuery = psHashAlloc(10);
+        psMemSetPersistent(preparedQuery, true);
     }
 
@@ -891,7 +892,7 @@
 
             // end lock on query cache
-//            if (psMemGetThreadSafety()) {
-//                pthread_mutex_unlock(&preparedQueryMutex);
-//            }
+            if (psMemGetThreadSafety()) {
+                pthread_mutex_unlock(&preparedQueryMutex);
+            }
 
             return -1;
@@ -905,7 +906,7 @@
 
     // end lock on query cache
-//    if (psMemGetThreadSafety()) {
-//        pthread_mutex_unlock(&preparedQueryMutex);
-//    }
+    if (psMemGetThreadSafety()) {
+        pthread_mutex_unlock(&preparedQueryMutex);
+    }
 
     psFree(query);
