diff --git a/src/daapd.h b/src/daapd.h index 85501bfd..c38a6726 100644 --- a/src/daapd.h +++ b/src/daapd.h @@ -50,6 +50,7 @@ typedef struct tag_config { int use_mdns; /**< Should we do rendezvous advertisements? */ int stop; /**< Time to exit? */ int reload; /**< Time to reload and/or rescan the database? */ + int foreground; /**< Whether or not we are running in foreground */ #if 0 char *configfile; /**< path to config file */ diff --git a/src/db-sql-sqlite3.c b/src/db-sql-sqlite3.c index e59f8a6b..04231f21 100644 --- a/src/db-sql-sqlite3.c +++ b/src/db-sql-sqlite3.c @@ -183,13 +183,14 @@ int db_sqlite3_exec(char **pe, int loglevel, char *fmt, ...) { int err; char *perr; + db_sqlite3_lock(); + va_start(ap,fmt); query=sqlite3_vmprintf(fmt,ap); va_end(ap); DPRINTF(E_DBG,L_DB,"Executing: %s\n",query); - db_sqlite3_lock(); err=sqlite3_exec(db_sqlite3_songs,query,NULL,NULL,&perr); if(err != SQLITE_OK) { db_get_error(pe,DB_E_SQL_ERROR,perr); @@ -424,7 +425,13 @@ int db_sqlite3_event(int event_type) { */ int db_sqlite3_insert_id(void) { - return (int)sqlite3_last_insert_rowid(db_sqlite3_songs); + int result; + + db_sqlite3_lock(); + result = (int)sqlite3_last_insert_rowid(db_sqlite3_songs); + db_sqlite3_unlock(); + + return result; }