return "SQLite";
}
+/*
+ * When using mult_db_connections = 1,
+ * sqlite can be BUSY. We just need sleep a little in this case.
+ */
+
+#ifdef HAVE_SQLITE3
+static int my_busy_handler(void *arg, int calls)
+{
+ bmicrosleep(0, 500);
+ return 1;
+}
+#else
+static int my_busy_handler(void *arg, const char* p, int calls)
+{
+ bmicrosleep(0, 500);
+ return 1;
+}
+#endif
+
+
/*
* Initialize database data structure. In principal this should
* never have errors, or it is really fatal.
mdb->fname = get_pool_memory(PM_FNAME);
mdb->path = get_pool_memory(PM_FNAME);
mdb->esc_name = get_pool_memory(PM_FNAME);
- mdb->esc_name2 = get_pool_memory(PM_FNAME);
+ mdb->esc_path = get_pool_memory(PM_FNAME);
mdb->allow_transactions = mult_db_connections;
qinsert(&db_list, &mdb->bq); /* put db in list */
V(mutex);
free(db_name);
V(mutex);
return 0;
- }
+ }
+ mdb->connected = true;
free(db_name);
if (!check_tables_version(jcr, mdb)) {
V(mutex);
return 0;
}
- mdb->connected = true;
+ /* set busy handler to wait when we use mult_db_connections = 1 */
+#ifdef HAVE_SQLITE3
+ sqlite3_busy_handler(mdb->db, my_busy_handler, NULL);
+#else
+ sqlite_busy_handler(mdb->db, my_busy_handler, NULL);
+#endif
+
V(mutex);
return 1;
}
}
db_end_transaction(jcr, mdb);
P(mutex);
+ sql_free_result(mdb);
mdb->ref_count--;
if (mdb->ref_count == 0) {
qdchain(&mdb->bq);
free_pool_memory(mdb->fname);
free_pool_memory(mdb->path);
free_pool_memory(mdb->esc_name);
- free_pool_memory(mdb->esc_name2);
+ free_pool_memory(mdb->esc_path);
if (mdb->db_name) {
free(mdb->db_name);
}