diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 15:10:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 15:10:48 +0000 |
commit | 354ea5b2cb270d3c5702a6fd4b7bbf88bf46272b (patch) | |
tree | 0d2a528e28422cf947f03795afbc1e8e9ad1db22 | |
parent | 01fbc4dc6f6846b7c62d3639e539ad16f812acf8 (diff) | |
download | gnunet-gtk-354ea5b2cb270d3c5702a6fd4b7bbf88bf46272b.tar.gz gnunet-gtk-354ea5b2cb270d3c5702a6fd4b7bbf88bf46272b.zip |
create dummy task to keep scheduler alive
-rw-r--r-- | src/fs/gnunet-fs-gtk.c | 1 | ||||
-rw-r--r-- | src/lib/eventloop.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 1803504e..8f05dfae 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -221,6 +221,7 @@ run (void *cls, | |||
221 | gtk_widget_show (main_window); | 221 | gtk_widget_show (main_window); |
222 | gtk_window_present (GTK_WINDOW (main_window)); | 222 | gtk_window_present (GTK_WINDOW (main_window)); |
223 | } | 223 | } |
224 | |||
224 | } | 225 | } |
225 | 226 | ||
226 | 227 | ||
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c index 6c457b14..67a78f50 100644 --- a/src/lib/eventloop.c +++ b/src/lib/eventloop.c | |||
@@ -90,6 +90,12 @@ struct GNUNET_GTK_MainLoop | |||
90 | */ | 90 | */ |
91 | guint cached_poll_array_size; | 91 | guint cached_poll_array_size; |
92 | 92 | ||
93 | /** | ||
94 | * Task we keep around just to keep the event loop running. | ||
95 | */ | ||
96 | GNUNET_SCHEDULER_TaskIdentifier dummy_task; | ||
97 | |||
98 | |||
93 | #if WINDOWS | 99 | #if WINDOWS |
94 | /** | 100 | /** |
95 | * Array to hold pipe handles during a select() call | 101 | * Array to hold pipe handles during a select() call |
@@ -148,6 +154,7 @@ struct GNUNET_GTK_MainLoop | |||
148 | }; | 154 | }; |
149 | 155 | ||
150 | 156 | ||
157 | |||
151 | /** | 158 | /** |
152 | * Get the configuration. | 159 | * Get the configuration. |
153 | * | 160 | * |
@@ -170,6 +177,8 @@ void | |||
170 | GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml) | 177 | GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml) |
171 | { | 178 | { |
172 | g_main_loop_quit (ml->gml); | 179 | g_main_loop_quit (ml->gml); |
180 | GNUNET_SCHEDULER_cancel (ml->dummy_task); | ||
181 | ml->dummy_task = GNUNET_SCHEDULER_NO_TASK; | ||
173 | } | 182 | } |
174 | 183 | ||
175 | 184 | ||
@@ -221,6 +230,21 @@ resize_cached_poll_array (struct GNUNET_GTK_MainLoop *ml, | |||
221 | } | 230 | } |
222 | 231 | ||
223 | 232 | ||
233 | /** | ||
234 | * Dummy task to keep our scheduler running. | ||
235 | */ | ||
236 | static void | ||
237 | keepalive_task (void *cls, | ||
238 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
239 | { | ||
240 | struct GNUNET_GTK_MainLoop *ml = cls; | ||
241 | |||
242 | ml->dummy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
243 | &keepalive_task, | ||
244 | ml); | ||
245 | } | ||
246 | |||
247 | |||
224 | #ifndef FD_COPY | 248 | #ifndef FD_COPY |
225 | #define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set))) | 249 | #define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set))) |
226 | #endif | 250 | #endif |
@@ -806,6 +830,12 @@ run_main_loop (void *cls, | |||
806 | /* start the Gtk event loop */ | 830 | /* start the Gtk event loop */ |
807 | GNUNET_assert (TRUE == g_main_context_acquire (ml->gmc)); | 831 | GNUNET_assert (TRUE == g_main_context_acquire (ml->gmc)); |
808 | GNUNET_SCHEDULER_set_select (&gnunet_gtk_select, ml); | 832 | GNUNET_SCHEDULER_set_select (&gnunet_gtk_select, ml); |
833 | |||
834 | /* keep Gtk event loop running even if there are no GNUnet tasks */ | ||
835 | ml->dummy_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
836 | &keepalive_task, | ||
837 | ml); | ||
838 | |||
809 | } | 839 | } |
810 | 840 | ||
811 | 841 | ||