diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-11 00:27:44 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-11 00:27:44 +0100 |
commit | 098b9d48733cf2374e4c1c6f4d9ec733edfe59d5 (patch) | |
tree | 9f6e065a9253ef1db8749d1b061414a891f10cda | |
parent | d533c72c5729ae7715b464f88e169b7993e77eb7 (diff) | |
download | messenger-gtk-098b9d48733cf2374e4c1c6f4d9ec733edfe59d5.tar.gz messenger-gtk-098b9d48733cf2374e4c1c6f4d9ec733edfe59d5.zip |
Implemented workaround to delays with the scheduler
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/chat/messenger.c | 21 | ||||
-rw-r--r-- | src/chat/messenger.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/chat/messenger.c b/src/chat/messenger.c index eb8523b..ad05158 100644 --- a/src/chat/messenger.c +++ b/src/chat/messenger.c | |||
@@ -42,6 +42,9 @@ _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 (app->chat.messenger.idle) | ||
46 | GNUNET_SCHEDULER_cancel(app->chat.messenger.idle); | ||
47 | |||
45 | MESSENGER_ApplicationSignal signal; | 48 | MESSENGER_ApplicationSignal signal; |
46 | int received = read(app->chat.pipe[0], &signal, sizeof(signal)); | 49 | int received = read(app->chat.pipe[0], &signal, sizeof(signal)); |
47 | 50 | ||
@@ -60,6 +63,19 @@ _chat_messenger_quit(void *cls) | |||
60 | GNUNET_SCHEDULER_shutdown(); | 63 | GNUNET_SCHEDULER_shutdown(); |
61 | } | 64 | } |
62 | 65 | ||
66 | static void | ||
67 | _chat_messenger_idle(void *cls) | ||
68 | { | ||
69 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
70 | |||
71 | app->chat.messenger.idle = GNUNET_SCHEDULER_add_delayed_with_priority( | ||
72 | GNUNET_TIME_relative_get_second_(), | ||
73 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
74 | &_chat_messenger_idle, | ||
75 | app | ||
76 | ); | ||
77 | } | ||
78 | |||
63 | static int | 79 | static int |
64 | _chat_messenger_message(void *cls, | 80 | _chat_messenger_message(void *cls, |
65 | struct GNUNET_CHAT_Context *context, | 81 | struct GNUNET_CHAT_Context *context, |
@@ -186,5 +202,10 @@ chat_messenger_run(void *cls, | |||
186 | app | 202 | app |
187 | ); | 203 | ); |
188 | 204 | ||
205 | app->chat.messenger.idle = GNUNET_SCHEDULER_add_now( | ||
206 | &_chat_messenger_idle, | ||
207 | app | ||
208 | ); | ||
209 | |||
189 | GNUNET_NETWORK_fdset_destroy(fd); | 210 | GNUNET_NETWORK_fdset_destroy(fd); |
190 | } | 211 | } |
diff --git a/src/chat/messenger.h b/src/chat/messenger.h index 888e4cd..bc07119 100644 --- a/src/chat/messenger.h +++ b/src/chat/messenger.h | |||
@@ -36,6 +36,7 @@ typedef struct CHAT_MESSENGER_Handle | |||
36 | { | 36 | { |
37 | struct GNUNET_CHAT_Handle *handle; | 37 | struct GNUNET_CHAT_Handle *handle; |
38 | struct GNUNET_SCHEDULER_Task *quit; | 38 | struct GNUNET_SCHEDULER_Task *quit; |
39 | struct GNUNET_SCHEDULER_Task *idle; | ||
39 | } CHAT_MESSENGER_Handle; | 40 | } CHAT_MESSENGER_Handle; |
40 | 41 | ||
41 | void | 42 | void |