[3070] in BarnOwl Developers
[PATCH 6/9] Post a quit task to the logging thread's mainloop instead of quitting directly
daemon@ATHENA.MIT.EDU (Adam Glasgall)
Wed May 25 18:15:18 2011
From: Adam Glasgall <glasgall@MIT.EDU>
To: barnowl-dev@mit.edu
Cc: Adam Glasgall <adam@crossproduct.net>
Date: Wed, 25 May 2011 18:14:52 -0400
In-Reply-To: <1306361695-13747-1-git-send-email-glasgall@mit.edu>
From: Adam Glasgall <adam@crossproduct.net>
Calling g_main_quit() on the main thread to quit the logging thread could resultin log tasks still in its queue getting lost. Instead, after we've shut down
everything that could log messages, post a quit task to the log thread so that
it'll only get run after everything outstanding has been processed.
---
logging.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/logging.c b/logging.c
index 4f1424a..a54df0e 100644
--- a/logging.c
+++ b/logging.c
@@ -453,8 +453,14 @@ void owl_log_init()
}
-void owl_log_shutdown()
+static gboolean owl_log_quit_func(gpointer data)
{
g_main_loop_quit(log_loop);
+ return FALSE;
+}
+
+void owl_log_shutdown()
+{
+ owl_select_post_task(owl_log_quit_func,NULL,NULL,log_context);
g_thread_join(logging_thread);
}
--
1.7.2.3