From: Eric Bollengier Date: Tue, 27 Mar 2007 19:21:12 +0000 (+0000) Subject: ebl Add a busy handler to use multi db connection with sqlite X-Git-Tag: Release-7.0.0~6691 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7c90f06a4c8c476a29e40a68a9374e9a2acd7db3;p=bacula%2Fbacula ebl Add a busy handler to use multi db connection with sqlite git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4434 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 32dd34853d..3d0007b4c4 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -69,6 +69,26 @@ db_get_type(void) 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. @@ -190,6 +210,13 @@ db_open_database(JCR *jcr, B_DB *mdb) return 0; } + /* 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 + mdb->connected = true; V(mutex); return 1;