[Asterisk-code-review] res_config_sqlite3: Only join threads that we started (...asterisk[16])

Friendly Automation asteriskteam at digium.com
Wed Jul 24 18:56:58 CDT 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11619 )

Change subject: res_config_sqlite3: Only join threads that we started
......................................................................

res_config_sqlite3: Only join threads that we started

ASTERISK-28477 #close
Reported by: Dennis

ASTERISK-28478 #close
Reported by: Dennis

Change-Id: I77347ad46a86dc5b35ed68270cee56acefb4f475
---
M res/res_config_sqlite3.c
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c
index 6446f17..4d99c79 100644
--- a/res/res_config_sqlite3.c
+++ b/res/res_config_sqlite3.c
@@ -102,6 +102,7 @@
 	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 @@
 	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);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11619
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I77347ad46a86dc5b35ed68270cee56acefb4f475
Gerrit-Change-Number: 11619
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190724/4329e73b/attachment.html>


More information about the asterisk-code-review mailing list