mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
exit threads in cmdline-util using join()
This commit is contained in:
parent
e6aa2dfa43
commit
8e4b79999b
1 changed files with 24 additions and 10 deletions
|
@ -137,10 +137,11 @@ static void* inbox_thread_entry_point (void* entry_arg)
|
||||||
// and MUST be called sequentially.
|
// and MUST be called sequentially.
|
||||||
dc_perform_imap_jobs(context);
|
dc_perform_imap_jobs(context);
|
||||||
dc_perform_imap_fetch(context);
|
dc_perform_imap_fetch(context);
|
||||||
|
if (run_threads) {
|
||||||
dc_perform_imap_idle(context); // this may take hours ...
|
dc_perform_imap_idle(context); // this may take hours ...
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inbox_thread = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,10 +155,11 @@ static void* mvbox_thread_entry_point (void* entry_arg)
|
||||||
// fetch() and idle() MUST be called from the same single thread
|
// fetch() and idle() MUST be called from the same single thread
|
||||||
// and MUST be called sequentially.
|
// and MUST be called sequentially.
|
||||||
dc_perform_mvbox_fetch(context);
|
dc_perform_mvbox_fetch(context);
|
||||||
|
if (run_threads) {
|
||||||
dc_perform_mvbox_idle(context); // this may take hours ...
|
dc_perform_mvbox_idle(context); // this may take hours ...
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mvbox_thread = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,10 +173,11 @@ static void* smtp_thread_entry_point (void* entry_arg)
|
||||||
// jobs() and idle() MUST be called from the same single thread
|
// jobs() and idle() MUST be called from the same single thread
|
||||||
// and MUST be called sequentially.
|
// and MUST be called sequentially.
|
||||||
dc_perform_smtp_jobs(context);
|
dc_perform_smtp_jobs(context);
|
||||||
|
if (run_threads) {
|
||||||
dc_perform_smtp_idle(context); // this may take hours ...
|
dc_perform_smtp_idle(context); // this may take hours ...
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
smtp_thread = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,10 +206,13 @@ static void stop_threads(dc_context_t* context)
|
||||||
dc_interrupt_mvbox_idle(context);
|
dc_interrupt_mvbox_idle(context);
|
||||||
dc_interrupt_smtp_idle(context);
|
dc_interrupt_smtp_idle(context);
|
||||||
|
|
||||||
// wait until the threads are finished
|
pthread_join(inbox_thread, NULL);
|
||||||
while (inbox_thread || mvbox_thread || smtp_thread) {
|
pthread_join(mvbox_thread, NULL);
|
||||||
usleep(100*1000);
|
pthread_join(smtp_thread, NULL);
|
||||||
}
|
|
||||||
|
inbox_thread = 0;
|
||||||
|
mvbox_thread = 0;
|
||||||
|
smtp_thread = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,6 +258,14 @@ int main(int argc, char ** argv)
|
||||||
stress_functions(context);
|
stress_functions(context);
|
||||||
s_do_log_info = 1;
|
s_do_log_info = 1;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for(int i=0; i<10000;i++) {
|
||||||
|
printf("--%i--\n", i);
|
||||||
|
start_threads(context);
|
||||||
|
stop_threads(context);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("Delta Chat Core is awaiting your commands.\n");
|
printf("Delta Chat Core is awaiting your commands.\n");
|
||||||
|
|
||||||
/* wait for command */
|
/* wait for command */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue