aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-06-27 19:26:33 +0000
committerChristian Grothoff <christian@grothoff.org>2008-06-27 19:26:33 +0000
commit4cbd002f3aaa8c068ea4063be309c8c1e15a489b (patch)
tree8aa84450aef2ce9d1f962d9e3845011d4cc6eed8
parent30fd9ccc87d4621a3622b329b3074bab9ed6cedf (diff)
downloadgnunet-gtk-4cbd002f3aaa8c068ea4063be309c8c1e15a489b.tar.gz
gnunet-gtk-4cbd002f3aaa8c068ea4063be309c8c1e15a489b.zip
handle logs during shutdown
-rw-r--r--src/common/helper.c2
-rw-r--r--src/common/logging.c12
-rw-r--r--src/core/main.c3
-rw-r--r--src/include/gnunetgtk_common.h3
4 files changed, 19 insertions, 1 deletions
diff --git a/src/common/helper.c b/src/common/helper.c
index 1090fefa..864051a9 100644
--- a/src/common/helper.c
+++ b/src/common/helper.c
@@ -142,6 +142,7 @@ GNUNET_GTK_save_call (GNUNET_ThreadMainFunction func, void *args)
142 GNUNET_mutex_lock (sclock); 142 GNUNET_mutex_lock (sclock);
143 if ((saveCallsUp == GNUNET_NO) || (!GNUNET_thread_test_self (mainThread))) 143 if ((saveCallsUp == GNUNET_NO) || (!GNUNET_thread_test_self (mainThread)))
144 { 144 {
145 GNUNET_GE_ASSERT(NULL, saveCallsUp != GNUNET_SYSERR);
145 call.args = args; 146 call.args = args;
146 call.func = func; 147 call.func = func;
147 call.sem = GNUNET_semaphore_create (0); 148 call.sem = GNUNET_semaphore_create (0);
@@ -417,6 +418,7 @@ GNUNET_GTK_shutdown_plugins ()
417 i = pscCount; 418 i = pscCount;
418 GNUNET_mutex_unlock (sclock); 419 GNUNET_mutex_unlock (sclock);
419 } 420 }
421 saveCallsUp = GNUNET_SYSERR;
420} 422}
421 423
422void 424void
diff --git a/src/common/logging.c b/src/common/logging.c
index 677c4783..e5ddcea8 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -32,6 +32,8 @@
32 32
33static GtkWidget *infoWindowTextView; 33static GtkWidget *infoWindowTextView;
34 34
35static int is_shutdown;
36
35static void 37static void
36init () 38init ()
37{ 39{
@@ -127,6 +129,8 @@ GNUNET_GTK_add_log_entry (const char *txt, ...)
127 va_list args; 129 va_list args;
128 gchar *note; 130 gchar *note;
129 131
132 if (is_shutdown)
133 return;
130 va_start (args, txt); 134 va_start (args, txt);
131 note = g_strdup_vprintf (txt, args); 135 note = g_strdup_vprintf (txt, args);
132 va_end (args); 136 va_end (args);
@@ -139,9 +143,17 @@ static void
139ge_gtk_log_handler (void *ctx, 143ge_gtk_log_handler (void *ctx,
140 GNUNET_GE_KIND kind, const char *date, const char *msg) 144 GNUNET_GE_KIND kind, const char *date, const char *msg)
141{ 145{
146 if (is_shutdown)
147 return;
142 GNUNET_GTK_show_info_message ("%s: %s", date, msg); 148 GNUNET_GTK_show_info_message ("%s: %s", date, msg);
143} 149}
144 150
151void
152GNUNET_GTK_shutdown_logger()
153{
154 is_shutdown = GNUNET_YES;
155}
156
145struct GNUNET_GE_Context * 157struct GNUNET_GE_Context *
146GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask) 158GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask)
147{ 159{
diff --git a/src/core/main.c b/src/core/main.c
index 52dc2a12..cd8062de 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -159,8 +159,9 @@ main (int argc, char *const *argv)
159 gtk_main (); 159 gtk_main ();
160 gdk_threads_leave (); 160 gdk_threads_leave ();
161 GNUNET_GE_setDefaultContext (ectx); 161 GNUNET_GE_setDefaultContext (ectx);
162 GNUNET_GTK_shutdown_logger();
163 GNUNET_GTK_shutdown_common_library ();
162 GNUNET_GE_free_context (my_ctx); 164 GNUNET_GE_free_context (my_ctx);
163 GNUNET_GTK_shutdown_common_library ();
164 GNUNET_fini (ectx, cfg); 165 GNUNET_fini (ectx, cfg);
165 return 0; 166 return 0;
166} 167}
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h
index ff8e9034..678a5a71 100644
--- a/src/include/gnunetgtk_common.h
+++ b/src/include/gnunetgtk_common.h
@@ -91,6 +91,9 @@ void GNUNET_GTK_add_log_entry (const char *txt, ...);
91 91
92struct GNUNET_GE_Context *GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask); 92struct GNUNET_GE_Context *GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask);
93 93
94void
95GNUNET_GTK_shutdown_logger();
96
94#define GNUNET_GTK_NOTIFY_LEVEL_LOW 0 97#define GNUNET_GTK_NOTIFY_LEVEL_LOW 0
95#define GNUNET_GTK_NOTIFY_LEVEL_NORMAL 1 98#define GNUNET_GTK_NOTIFY_LEVEL_NORMAL 1
96#define GNUNET_GTK_NOTIFY_LEVEL_CRITICAL 2 99#define GNUNET_GTK_NOTIFY_LEVEL_CRITICAL 2