You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2006/04/27 05:26:16 UTC

svn commit: r397377 - /apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c

Author: bojan
Date: Wed Apr 26 20:26:13 2006
New Revision: 397377

URL: http://svn.apache.org/viewcvs?rev=397377&view=rev
Log:
Rework commit 396309 from trunk to apply to 1.2.x (mutex lock code adjustment required to merge)

Modified:
    apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c

Modified: apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c?rev=397377&r1=397376&r2=397377&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c (original)
+++ apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c Wed Apr 26 20:26:13 2006
@@ -245,12 +245,24 @@
     apr_thread_mutex_lock(sql->mutex);
 
     do {
+        int retry_count = 0;
+
         ret = sqlite3_prepare(sql->conn, query, length, &stmt, &tail);
         if (ret != SQLITE_OK) {
             sqlite3_finalize(stmt);
             break;
         }
-        ret = sqlite3_step(stmt);
+
+        while(retry_count++ <= MAX_RETRY_COUNT) {
+            ret = sqlite3_step(stmt);
+            if (ret != SQLITE_BUSY)
+                break;
+
+            apr_thread_mutex_unlock(sql->mutex);
+            apr_sleep(MAX_RETRY_SLEEP);
+            apr_thread_mutex_lock(sql->mutex);
+        }
+
         *nrows = sqlite3_changes(sql->conn);
         sqlite3_finalize(stmt);
         length -= (tail - query);