From 49a447c3d44af7c3a7f6fab892d99cae5a1614b5 Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Sun, 28 May 2017 13:17:40 +0200 Subject: [PATCH] Combine 'global' with connection code --- src/connection.c | 11 +++++++---- src/connection.h | 5 ++++- src/global.c | 27 --------------------------- src/global.h | 24 ------------------------ src/input/evdev.c | 1 - src/loop.c | 2 +- 6 files changed, 12 insertions(+), 58 deletions(-) delete mode 100644 src/global.c delete mode 100644 src/global.h diff --git a/src/connection.c b/src/connection.c index f25a508..9838350 100644 --- a/src/connection.c +++ b/src/connection.c @@ -18,12 +18,15 @@ */ #include "connection.h" -#include "global.h" #include +#include -static void connection_connection_terminated() { - quit(); +pthread_t main_thread_id = 0; + +static void connection_terminated() { + if (main_thread_id != 0) + pthread_kill(main_thread_id, SIGTERM); } static void connection_display_message(const char *msg) { @@ -39,7 +42,7 @@ CONNECTION_LISTENER_CALLBACKS connection_callbacks = { .stageComplete = NULL, .stageFailed = NULL, .connectionStarted = NULL, - .connectionTerminated = connection_connection_terminated, + .connectionTerminated = connection_terminated, .displayMessage = connection_display_message, .displayTransientMessage = connection_display_transient_message, }; diff --git a/src/connection.h b/src/connection.h index 8b985b6..009e787 100644 --- a/src/connection.h +++ b/src/connection.h @@ -1,7 +1,7 @@ /* * This file is part of Moonlight Embedded. * - * Copyright (C) 2015 Iwan Timmer + * Copyright (C) 2015-2017 Iwan Timmer * * Moonlight is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,4 +19,7 @@ #include +#include + extern CONNECTION_LISTENER_CALLBACKS connection_callbacks; +extern pthread_t main_thread_id; diff --git a/src/global.c b/src/global.c deleted file mode 100644 index c5992ba..0000000 --- a/src/global.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of Moonlight Embedded. - * - * Copyright (C) 2015 Iwan Timmer - * - * Moonlight is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Moonlight is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Moonlight; if not, see . - */ - -#include -#include - -pthread_t main_thread_id; - -void quit() { - pthread_kill(main_thread_id, SIGTERM); -} diff --git a/src/global.h b/src/global.h deleted file mode 100644 index f558716..0000000 --- a/src/global.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of Moonlight Embedded. - * - * Copyright (C) 2015 Iwan Timmer - * - * Moonlight is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Moonlight is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Moonlight; if not, see . - */ - -#include - -extern pthread_t main_thread_id; - -void quit(); diff --git a/src/input/evdev.c b/src/input/evdev.c index 0501d7a..2adf713 100644 --- a/src/input/evdev.c +++ b/src/input/evdev.c @@ -18,7 +18,6 @@ */ #include "../loop.h" -#include "../global.h" #include "keyboard.h" #include "mapping.h" diff --git a/src/loop.c b/src/loop.c index 10f80ba..c7b68f4 100644 --- a/src/loop.c +++ b/src/loop.c @@ -19,7 +19,7 @@ #include "loop.h" -#include "global.h" +#include "connection.h" #include #include