diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-04-17 17:34:30 +0200 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-04-17 17:34:30 +0200 |
commit | 9ad1e9f834085b034262f9724400bcb52b55b70c (patch) | |
tree | 23f1e8df1fd843310a1052eb120012eaec142816 /src/application.c | |
parent | 6e6a4f7f612c14fa0188eab6fc6e2906b717540b (diff) | |
download | messenger-gtk-9ad1e9f834085b034262f9724400bcb52b55b70c.tar.gz messenger-gtk-9ad1e9f834085b034262f9724400bcb52b55b70c.zip |
Added some comments for clarification
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/application.c')
-rw-r--r-- | src/application.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/application.c b/src/application.c index 1ae2f88..67bfc82 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -254,6 +254,7 @@ _application_chat_thread(void *args) | |||
254 | void | 254 | void |
255 | application_run(MESSENGER_Application *app) | 255 | application_run(MESSENGER_Application *app) |
256 | { | 256 | { |
257 | // Start thread to run GNUnet scheduler | ||
257 | pthread_create(&(app->chat.tid), NULL, _application_chat_thread, app); | 258 | pthread_create(&(app->chat.tid), NULL, _application_chat_thread, app); |
258 | 259 | ||
259 | app->ui.status = g_application_run( | 260 | app->ui.status = g_application_run( |
@@ -265,6 +266,7 @@ application_run(MESSENGER_Application *app) | |||
265 | if (app->ui.status != 0) | 266 | if (app->ui.status != 0) |
266 | application_exit(app, MESSENGER_FAIL); | 267 | application_exit(app, MESSENGER_FAIL); |
267 | 268 | ||
269 | // Wait for other thread to stop properly | ||
268 | pthread_join(app->chat.tid, NULL); | 270 | pthread_join(app->chat.tid, NULL); |
269 | 271 | ||
270 | close(app->chat.pipe[0]); | 272 | close(app->chat.pipe[0]); |
@@ -272,6 +274,7 @@ application_run(MESSENGER_Application *app) | |||
272 | 274 | ||
273 | pthread_mutex_destroy(&(app->chat.mutex)); | 275 | pthread_mutex_destroy(&(app->chat.mutex)); |
274 | 276 | ||
277 | // Get rid of open notifications | ||
275 | GList *list = app->notifications; | 278 | GList *list = app->notifications; |
276 | 279 | ||
277 | while (list) { | 280 | while (list) { |
@@ -304,6 +307,7 @@ _application_event_call(gpointer user_data) | |||
304 | 307 | ||
305 | call = (MESSENGER_ApplicationEventCall*) user_data; | 308 | call = (MESSENGER_ApplicationEventCall*) user_data; |
306 | 309 | ||
310 | // Locking the mutex for synchronization | ||
307 | pthread_mutex_lock(&(call->app->chat.mutex)); | 311 | pthread_mutex_lock(&(call->app->chat.mutex)); |
308 | call->event(call->app); | 312 | call->event(call->app); |
309 | pthread_mutex_unlock(&(call->app->chat.mutex)); | 313 | pthread_mutex_unlock(&(call->app->chat.mutex)); |
@@ -344,6 +348,7 @@ _application_message_event_call(gpointer user_data) | |||
344 | 348 | ||
345 | call = (MESSENGER_ApplicationMessageEventCall*) user_data; | 349 | call = (MESSENGER_ApplicationMessageEventCall*) user_data; |
346 | 350 | ||
351 | // Locking the mutex for synchronization | ||
347 | pthread_mutex_lock(&(call->app->chat.mutex)); | 352 | pthread_mutex_lock(&(call->app->chat.mutex)); |
348 | call->event(call->app, call->context, call->message); | 353 | call->event(call->app, call->context, call->message); |
349 | pthread_mutex_unlock(&(call->app->chat.mutex)); | 354 | pthread_mutex_unlock(&(call->app->chat.mutex)); |
@@ -380,6 +385,8 @@ void | |||
380 | application_exit(MESSENGER_Application *app, | 385 | application_exit(MESSENGER_Application *app, |
381 | MESSENGER_ApplicationSignal signal) | 386 | MESSENGER_ApplicationSignal signal) |
382 | { | 387 | { |
388 | // Forward a signal to the other thread causing it to shutdown the | ||
389 | // GNUnet handles of the application. | ||
383 | write(app->chat.pipe[1], &signal, sizeof(signal)); | 390 | write(app->chat.pipe[1], &signal, sizeof(signal)); |
384 | } | 391 | } |
385 | 392 | ||