diff options
Diffstat (limited to 'src/chat/messenger.c')
-rw-r--r-- | src/chat/messenger.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/chat/messenger.c b/src/chat/messenger.c index bea3299..eb8523b 100644 --- a/src/chat/messenger.c +++ b/src/chat/messenger.c | |||
@@ -38,21 +38,15 @@ _chat_messenger_destroy_contacts(UNUSED void *cls, | |||
38 | } | 38 | } |
39 | 39 | ||
40 | static void | 40 | static void |
41 | _chat_messenger_idle(void *cls) | 41 | _chat_messenger_quit(void *cls) |
42 | { | 42 | { |
43 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 43 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
44 | 44 | ||
45 | if (MESSENGER_NONE == app->chat.signal) | 45 | MESSENGER_ApplicationSignal signal; |
46 | { | 46 | int received = read(app->chat.pipe[0], &signal, sizeof(signal)); |
47 | app->chat.messenger.idle = GNUNET_SCHEDULER_add_delayed_with_priority( | 47 | |
48 | GNUNET_TIME_relative_get_second_(), | 48 | if (received < 0) |
49 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 49 | signal = MESSENGER_FAIL; |
50 | &_chat_messenger_idle, | ||
51 | app | ||
52 | ); | ||
53 | |||
54 | return; | ||
55 | } | ||
56 | 50 | ||
57 | GNUNET_CHAT_iterate_contacts( | 51 | GNUNET_CHAT_iterate_contacts( |
58 | app->chat.messenger.handle, | 52 | app->chat.messenger.handle, |
@@ -63,8 +57,7 @@ _chat_messenger_idle(void *cls) | |||
63 | GNUNET_CHAT_stop(app->chat.messenger.handle); | 57 | GNUNET_CHAT_stop(app->chat.messenger.handle); |
64 | app->chat.messenger.handle = NULL; | 58 | app->chat.messenger.handle = NULL; |
65 | 59 | ||
66 | if (MESSENGER_QUIT != app->chat.signal) | 60 | GNUNET_SCHEDULER_shutdown(); |
67 | GNUNET_SCHEDULER_shutdown(); | ||
68 | } | 61 | } |
69 | 62 | ||
70 | static int | 63 | static int |
@@ -181,10 +174,17 @@ chat_messenger_run(void *cls, | |||
181 | app | 174 | app |
182 | ); | 175 | ); |
183 | 176 | ||
184 | app->chat.messenger.idle = GNUNET_SCHEDULER_add_delayed_with_priority( | 177 | struct GNUNET_NETWORK_FDSet *fd = GNUNET_NETWORK_fdset_create (); |
185 | GNUNET_TIME_relative_get_zero_(), | 178 | GNUNET_NETWORK_fdset_set_native(fd, app->chat.pipe[0]); |
186 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 179 | |
187 | &_chat_messenger_idle, | 180 | app->chat.messenger.quit = GNUNET_SCHEDULER_add_select( |
181 | GNUNET_SCHEDULER_PRIORITY_URGENT, | ||
182 | GNUNET_TIME_relative_get_forever_(), | ||
183 | fd, | ||
184 | NULL, | ||
185 | &_chat_messenger_quit, | ||
188 | app | 186 | app |
189 | ); | 187 | ); |
188 | |||
189 | GNUNET_NETWORK_fdset_destroy(fd); | ||
190 | } | 190 | } |