[elephant-cvs] CVS update: elephant/src/libsleepycat.c

blee at common-lisp.net blee at common-lisp.net
Sun Aug 29 07:54:13 UTC 2004


Update of /project/elephant/cvsroot/elephant/src
In directory common-lisp.net:/tmp/cvs-serv32393/src

Modified Files:
	libsleepycat.c 
Log Message:
next_counter: release lock on error, DB_TXN_NOSYNC (speed!)

Date: Sun Aug 29 09:54:13 2004
Author: blee

Index: elephant/src/libsleepycat.c
diff -u elephant/src/libsleepycat.c:1.4 elephant/src/libsleepycat.c:1.5
--- elephant/src/libsleepycat.c:1.4	Sat Aug 28 08:40:33 2004
+++ elephant/src/libsleepycat.c	Sun Aug 29 09:54:13 2004
@@ -85,7 +85,7 @@
 
 /* Sleepycat stuff */
 
-#include <db42/db.h>
+#include <db.h>
 
 /* Environment */
 
@@ -417,7 +417,7 @@
   DB_LOCK lock;
   DBT DBTKey, DBTData; 
   DB_TXN *tid; 
-  int counter, tries, ret, t_ret;
+  int counter, tries, ret, t_ret, lockheld;
   u_int32_t id;
 
   /* Initialization. */ 
@@ -428,9 +428,12 @@
   DBTKey.size = key_length;
   DBTData.data = lockid;
   DBTData.size = lockid_length;
+
   tries = 0;
 
  loop:
+  lockheld = 0;
+
   /* Begin the transaction. */ 
   if ((ret = env->txn_begin(env, NULL, &tid, 0)) != 0) { 
     env->err(env, ret, "DB_ENV->txn_begin"); 
@@ -442,6 +445,8 @@
   if ((ret = env->lock_get(env, id, 0, &DBTData, DB_LOCK_WRITE, &lock)) != 0)
     goto fail;
 
+  lockheld = 1;
+
   memset(&DBTData, 0, sizeof(DBTData)); 
   DBTData.data = &counter;
   DBTData.ulen = sizeof(counter);
@@ -462,7 +467,7 @@
   if ((ret = env->lock_put(env, &lock)) != 0) 
     goto fail;
 
-  if ((ret = tid->commit(tid, 0)) != 0) { 
+  if ((ret = tid->commit(tid, DB_TXN_NOSYNC)) != 0) { 
     env->err(env, ret, "DB_TXN->commit"); 
     return (-2); 
   } 
@@ -470,12 +475,16 @@
 
 
  fail:
+  if (lockheld)
+    if ((ret = env->lock_put(env, &lock)) != 0) 
+      return (-3);
+
   /* Abort and retry the operation. */ 
   if ((t_ret = tid->abort(tid)) != 0) { 
     env->err(env, t_ret, "DB_TXN->abort"); 
-    return (-3);
+    return (-4);
   } 
   if (tries++ == 100)
-    return (-4); 
+    return (-5); 
   goto loop;
 }





More information about the Elephant-cvs mailing list