vine-tool: Handle SIGINT for glib event loop 43/260743/6
authorCheoleun Moon <chleun.moon@samsung.com>
Fri, 2 Jul 2021 05:38:32 +0000 (14:38 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Fri, 2 Jul 2021 06:37:07 +0000 (15:37 +0900)
Change-Id: I2c4d09f46595ee29a913b4954a5833bdebd8bbfe
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
tool/tool_main.cpp [changed mode: 0644->0755]
tool/tool_run.cpp
tool/tool_run.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 72c47d6..87f055a
@@ -7,10 +7,9 @@
 #include "tool_parse.h"
 #include "tool_run.h"
 
-int interrupt_flag = 0;
 static void interrupt_handler(int signo)
 {
-       interrupt_flag = 1;
+       stop_event_loop();
 }
 
 int main(int argc, char **argv)
index c76cadd17eebff04dd34c148e7b61e939e23f898..384bcc11a05482085ef474eeda82487cce467ddd 100755 (executable)
@@ -25,7 +25,7 @@
 #define MAX_EVENTS 10
 #define MAX_READ_LEN 1024
 
-extern int interrupt_flag;
+int interrupt_flag;
 
 static int epollfd = 0;
 static FILE *log_file = NULL;
@@ -71,6 +71,10 @@ static int send_message(vine_dp_h dp);
 static void _stop_message_timer(vine_dp_h dp);
 static int joined_peer = 0;
 
+#ifdef USE_VINE_EVENT_LOOP_EXTERNAL_GLIB
+static GMainLoop *main_loop = NULL;
+#endif
+
 static vine_dp_type_e _convert_dp_type(dp_type_t type)
 {
        switch (type) {
@@ -610,16 +614,27 @@ static void _event_handler(vine_session_h session)
        vine_session_process_event(session);
 }
 
-#ifdef BT_SUPPORT
+#ifdef USE_VINE_EVENT_LOOP_EXTERNAL_GLIB
 static void _run_glib_event_loop()
 {
-       GMainLoop *main_loop = g_main_loop_new(NULL, FALSE);
+       main_loop = g_main_loop_new(NULL, FALSE);
 
        g_main_loop_run(main_loop);
        g_main_loop_unref(main_loop);
 }
 
 #endif
+
+void stop_event_loop()
+{
+#ifdef USE_VINE_EVENT_LOOP_EXTERNAL_GLIB
+       if (main_loop)
+               g_main_loop_quit(main_loop);
+#else
+       interrupt_flag = 1;
+#endif
+}
+
 static void _run_epoll_event_loop(vine_session_h session)
 {
        int fd;
old mode 100644 (file)
new mode 100755 (executable)
index a00b9e6..c038361
@@ -1 +1,2 @@
 int tool_run();
+void stop_event_loop();