aboutsummaryrefslogtreecommitdiff
path: root/src/lib/eventloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eventloop.c')
-rw-r--r--src/lib/eventloop.c30
1 files changed, 30 insertions, 0 deletions
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
170GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml) 177GNUNET_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 */
236static void
237keepalive_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