From dd1b98316d538335d78bf933a0f180c99e3af32e Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 29 Jun 2018 00:14:12 +0200 Subject: [PATCH] in the demo, on exit, wait until the threads are finished; bug fixed --- cmdline/main.c | 5 +++++ src/dc_context.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmdline/main.c b/cmdline/main.c index 0b8a480f..d0d24881 100644 --- a/cmdline/main.c +++ b/cmdline/main.c @@ -186,6 +186,11 @@ static void stop_threads(dc_context_t* mailbox) imap_foreground = 0; dc_interrupt_imap_idle(mailbox); dc_interrupt_smtp_idle(mailbox); + + // wait until the threads are finished + while( imap_thread || smtp_thread ) { + usleep(100*1000); + } } diff --git a/src/dc_context.c b/src/dc_context.c index c67b63e0..42aa2b90 100644 --- a/src/dc_context.c +++ b/src/dc_context.c @@ -676,6 +676,8 @@ dc_chat_t* dc_get_chat(dc_context_t* context, uint32_t chat_id) goto cleanup; } + success = 1; + cleanup: if( success ) { return obj; @@ -3362,7 +3364,7 @@ void dc_marknoticed_contact(dc_context_t* context, uint32_t contact_id) void dc_block_chat(dc_context_t* context, uint32_t chat_id, int new_blocking) { - sqlite3_stmt* stmt; + sqlite3_stmt* stmt = NULL; if( context == NULL || context->m_magic != DC_CONTEXT_MAGIC ) { return;