]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_config_sqlite3: Only join threads that we started
authorSean Bright <sean.bright@gmail.com>
Tue, 23 Jul 2019 17:58:31 +0000 (13:58 -0400)
committerSean Bright <sean.bright@gmail.com>
Tue, 23 Jul 2019 18:09:36 +0000 (14:09 -0400)
ASTERISK-28477 #close
Reported by: Dennis

ASTERISK-28478 #close
Reported by: Dennis

Change-Id: I77347ad46a86dc5b35ed68270cee56acefb4f475

res/res_config_sqlite3.c

index 6148d5d8757845cc9d31dc7dbf7179b58b8677af..d321cb7c5df336ad0bc6c49c2f95fe3111e421a0 100644 (file)
@@ -104,6 +104,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;
 };
 
@@ -368,13 +369,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);