From: Sean Bright Date: Tue, 23 Jul 2019 17:58:31 +0000 (-0400) Subject: res_config_sqlite3: Only join threads that we started X-Git-Tag: 17.0.0-rc1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2424ecaf663465fd98b7d9548b40086a9eb417c2;p=thirdparty%2Fasterisk.git res_config_sqlite3: Only join threads that we started ASTERISK-28477 #close Reported by: Dennis ASTERISK-28478 #close Reported by: Dennis Change-Id: I77347ad46a86dc5b35ed68270cee56acefb4f475 --- diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c index 6446f172e6..4d99c79de4 100644 --- a/res/res_config_sqlite3.c +++ b/res/res_config_sqlite3.c @@ -102,6 +102,7 @@ struct realtime_sqlite3_db { unsigned int debug:1; unsigned int exiting:1; unsigned int wakeup:1; + unsigned int has_batch_thread:1; unsigned int batch; int busy_timeout; }; @@ -367,13 +368,14 @@ void db_start_batch(struct realtime_sqlite3_db *db) if (db->batch) { ast_cond_init(&db->cond, NULL); ao2_ref(db, +1); - ast_pthread_create_background(&db->syncthread, NULL, db_sync_thread, db); + db->has_batch_thread = !ast_pthread_create_background(&db->syncthread, NULL, db_sync_thread, db); } } void db_stop_batch(struct realtime_sqlite3_db *db) { - if (db->batch) { + if (db->has_batch_thread) { + db->has_batch_thread = 0; db->exiting = 1; db_sync(db); pthread_join(db->syncthread, NULL);