apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r396309 - /apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
Date Sun, 23 Apr 2006 19:29:41 GMT
Author: bojan
Date: Sun Apr 23 12:29:40 2006
New Revision: 396309

URL: http://svn.apache.org/viewcvs?rev=396309&view=rev
Log:
Retry SQLite3 query on BUSY

Modified:
    apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c

Modified: apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c?rev=396309&r1=396308&r2=396309&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c Sun Apr 23 12:29:40 2006
@@ -253,12 +253,24 @@
     apr_dbd_mutex_lock();
 
     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_dbd_mutex_unlock(sql->mutex);
+            apr_sleep(MAX_RETRY_SLEEP);
+            apr_dbd_mutex_lock(sql->mutex);
+        }
+
         *nrows = sqlite3_changes(sql->conn);
         sqlite3_finalize(stmt);
         length -= (tail - query);



Mime
View raw message