On Mon, 2006-04-17 at 16:11 +1000, Bojan Smojver wrote:
> I tested this patch with 1.2.x,
Yeah, and I also applied it to trunk as if it were for 1.2.x - sorry.
The mutex calls should be different. Here is a better version.
--
Bojan
Index: apr_dbd_sqlite3.c
===================================================================
--- apr_dbd_sqlite3.c (revision 394609)
+++ apr_dbd_sqlite3.c (working copy)
@@ -253,12 +253,29 @@
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 (dbd_sqlite3_is_success(ret))
+ break;
+
+ if (ret == SQLITE_BUSY){
+ apr_dbd_mutex_unlock(sql->mutex);
+ apr_sleep(MAX_RETRY_SLEEP);
+ apr_dbd_mutex_lock(sql->mutex);
+ continue;
+ } else {
+ break;
+ }
+ }
+
*nrows = sqlite3_changes(sql->conn);
sqlite3_finalize(stmt);
length -= (tail - query);