From fd0852a60d65c74bef554d8c1e9c57cbcb6f2bbd Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Thu, 2 Jul 2015 15:25:07 +0300 Subject: [PATCH] Don't wait longer than 10 sec for the task thread to terminate If the current task is stuck for too long after being canceled it's probably stuck forever. Let "too long" be 10 seconds. And let it get stuck forever in debug build only. --- app/src/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main.cpp b/app/src/main.cpp index 6b60e25..2b7f975 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -54,6 +54,16 @@ #include +// If the current task is stuck for too long after being canceled it's +// probably stuck forever. Let "too long" be 10 seconds. +#if HARBOUR_DEBUG + // But let it get stuck forever in debug build +# define TASK_QUEUE_TIMEOUT (-1) +#else + // There's no reason to wait forever in release build though. +# define TASK_QUEUE_TIMEOUT (10000) +#endif + int main(int argc, char **argv) { QGuiApplication* app = SailfishApp::application(argc, argv); @@ -85,7 +95,7 @@ int main(int argc, char **argv) BooksConfigManager configManager; if (ZLibrary::init(argc, argv)) { ZLibrary::run(NULL); - BooksTaskQueue::waitForDone(); + BooksTaskQueue::waitForDone(TASK_QUEUE_TIMEOUT); ZLibrary::shutdown(); }