In fact, this can be done even simpler. Reworked patch attached.

-- 
Bojan
Index: apr_dbd_sqlite3.c
===================================================================
--- apr_dbd_sqlite3.c	(revision 394781)
+++ apr_dbd_sqlite3.c	(working copy)
@@ -253,11 +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;
         }
+
+        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);
+        }
+
         ret = sqlite3_step(stmt);
         *nrows = sqlite3_changes(sql->conn);
         sqlite3_finalize(stmt);

Reply via email to