summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Kroitor <an.kroitor@samsung.com>2016-08-29 11:45:47 +0300
committerAndrii Kroitor <an.kroitor@samsung.com>2016-08-31 19:39:47 +0300
commit18ed6733577a49b5ec002d10231936f7aad8b410 (patch)
treeca1678071c327c94f303e8d43351e56d75cc5455
parenta918b341bbf716784de4318fb4cf117600d6b3a8 (diff)
fix eauto_disconnect logic
-rw-r--r--src/libeauto.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/libeauto.c b/src/libeauto.c
index 1ae716b..c42900f 100644
--- a/src/libeauto.c
+++ b/src/libeauto.c
@@ -44,24 +44,10 @@ _geometry_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, const c
44 ecore_thread_global_data_set(RESULT_KEY, obj, NULL); 44 ecore_thread_global_data_set(RESULT_KEY, obj, NULL);
45} 45}
46 46
47static Eina_Bool disconnect = EINA_FALSE;
48static const char *address; 47static const char *address;
49static unsigned int port; 48static unsigned int port;
50static pthread_t thread_id; 49static pthread_t thread_id;
51 50
52Eina_Bool
53_disconnect_timer(void *data EINA_UNUSED)
54{
55 if (disconnect)
56 {
57 printf("Here\n");
58 ecore_main_loop_quit();
59 disconnect = EINA_FALSE;
60 return ECORE_CALLBACK_CANCEL;
61 }
62 return ECORE_CALLBACK_RENEW;
63}
64
65static void * 51static void *
66connection_thread(void *data EINA_UNUSED) 52connection_thread(void *data EINA_UNUSED)
67{ 53{
@@ -89,7 +75,6 @@ connection_thread(void *data EINA_UNUSED)
89 ecore_con_eet_data_callback_add(ec_eet, EAUTO_OBJECT_STREAM, _object_cb, NULL); 75 ecore_con_eet_data_callback_add(ec_eet, EAUTO_OBJECT_STREAM, _object_cb, NULL);
90 ecore_con_eet_data_callback_add(ec_eet, EAUTO_GEOMETRY_STREAM, _geometry_cb, NULL); 76 ecore_con_eet_data_callback_add(ec_eet, EAUTO_GEOMETRY_STREAM, _geometry_cb, NULL);
91 77
92 ecore_timer_add(0.05, _disconnect_timer, NULL);
93 ecore_main_loop_begin(); 78 ecore_main_loop_begin();
94 79
95 // Delete all callbacks before closing connection. 80 // Delete all callbacks before closing connection.
@@ -117,11 +102,17 @@ eauto_connect(const char *saddr, unsigned int sport)
117 pthread_create(&thread_id, NULL, &connection_thread, NULL); 102 pthread_create(&thread_id, NULL, &connection_thread, NULL);
118} 103}
119 104
105static void *
106_quit(void *data EINA_UNUSED)
107{
108 ecore_main_loop_quit();
109 return NULL;
110}
111
120void 112void
121eauto_disconnect(void) 113eauto_disconnect(void)
122{ 114{
123 disconnect = EINA_TRUE; 115 ecore_main_loop_thread_safe_call_sync(_quit, NULL);
124 pthread_join(thread_id, NULL);
125} 116}
126 117
127void 118void