summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-09-21 16:19:26 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-09-21 16:19:53 -0700
commit72f0bfa2248b8e6595985827b042d94acc50bc76 (patch)
tree03976acd0b5d916a6691d511424e546bd231ac88
parent3c3c51f02970fe020897e8602396ac4808605e80 (diff)
ecore,ecore_con: simplify destructor by linking future life cycle with object.
-rw-r--r--src/lib/ecore/efl_io_copier.c4
-rw-r--r--src/lib/ecore_con/efl_net_dialer_tcp.c6
-rw-r--r--src/lib/ecore_con/efl_net_dialer_websocket.c13
3 files changed, 4 insertions, 19 deletions
diff --git a/src/lib/ecore/efl_io_copier.c b/src/lib/ecore/efl_io_copier.c
index ad9a38a361..1f571c8d2c 100644
--- a/src/lib/ecore/efl_io_copier.c
+++ b/src/lib/ecore/efl_io_copier.c
@@ -104,6 +104,7 @@ _efl_io_copier_job_schedule(Eo *o, Efl_Io_Copier_Data *pd)
104 104
105 efl_future_use(&pd->job, efl_loop_job(efl_loop_user_loop_get(o), o)); 105 efl_future_use(&pd->job, efl_loop_job(efl_loop_user_loop_get(o), o));
106 efl_future_then(pd->job, _efl_io_copier_job, NULL, NULL, o); 106 efl_future_then(pd->job, _efl_io_copier_job, NULL, NULL, o);
107 efl_future_link(o, pd->job);
107} 108}
108 109
109/* NOTE: the returned slice may be smaller than requested since the 110/* NOTE: the returned slice may be smaller than requested since the
@@ -690,9 +691,6 @@ _efl_io_copier_efl_object_destructor(Eo *o, Efl_Io_Copier_Data *pd)
690 efl_io_copier_source_set(o, NULL); 691 efl_io_copier_source_set(o, NULL);
691 efl_io_copier_destination_set(o, NULL); 692 efl_io_copier_destination_set(o, NULL);
692 693
693 if (pd->job)
694 efl_future_cancel(pd->job);
695
696 efl_destructor(efl_super(o, MY_CLASS)); 694 efl_destructor(efl_super(o, MY_CLASS));
697 695
698 if (pd->buf) 696 if (pd->buf)
diff --git a/src/lib/ecore_con/efl_net_dialer_tcp.c b/src/lib/ecore_con/efl_net_dialer_tcp.c
index c114d4d88a..b490aaa36f 100644
--- a/src/lib/ecore_con/efl_net_dialer_tcp.c
+++ b/src/lib/ecore_con/efl_net_dialer_tcp.c
@@ -60,9 +60,6 @@ _efl_net_dialer_tcp_efl_object_destructor(Eo *o, Efl_Net_Dialer_Tcp_Data *pd)
60 (!efl_io_closer_closed_get(o))) 60 (!efl_io_closer_closed_get(o)))
61 efl_io_closer_close(o); 61 efl_io_closer_close(o);
62 62
63 if (pd->connect.timeout)
64 efl_future_cancel(pd->connect.timeout);
65
66 if (pd->connect.thread) 63 if (pd->connect.thread)
67 { 64 {
68 ecore_thread_cancel(pd->connect.thread); 65 ecore_thread_cancel(pd->connect.thread);
@@ -82,8 +79,6 @@ _efl_net_dialer_tcp_connect_timeout(void *data, const Efl_Event *ev EINA_UNUSED)
82 Efl_Net_Dialer_Tcp_Data *pd = efl_data_scope_get(o, MY_CLASS); 79 Efl_Net_Dialer_Tcp_Data *pd = efl_data_scope_get(o, MY_CLASS);
83 Eina_Error err = ETIMEDOUT; 80 Eina_Error err = ETIMEDOUT;
84 81
85 pd->connect.timeout = NULL;
86
87 if (pd->connect.thread) 82 if (pd->connect.thread)
88 { 83 {
89 ecore_thread_cancel(pd->connect.thread); 84 ecore_thread_cancel(pd->connect.thread);
@@ -175,6 +170,7 @@ _efl_net_dialer_tcp_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Tcp_Data *pd EINA_
175 { 170 {
176 efl_future_use(&pd->connect.timeout, efl_loop_timeout(efl_loop_user_loop_get(o), pd->timeout_dial, o)); 171 efl_future_use(&pd->connect.timeout, efl_loop_timeout(efl_loop_user_loop_get(o), pd->timeout_dial, o));
177 efl_future_then(pd->connect.timeout, _efl_net_dialer_tcp_connect_timeout, NULL, NULL, o); 172 efl_future_then(pd->connect.timeout, _efl_net_dialer_tcp_connect_timeout, NULL, NULL, o);
173 efl_future_link(o, pd->connect.timeout);
178 } 174 }
179 175
180 return 0; 176 return 0;
diff --git a/src/lib/ecore_con/efl_net_dialer_websocket.c b/src/lib/ecore_con/efl_net_dialer_websocket.c
index fb126dd74e..52c066103f 100644
--- a/src/lib/ecore_con/efl_net_dialer_websocket.c
+++ b/src/lib/ecore_con/efl_net_dialer_websocket.c
@@ -740,8 +740,6 @@ _efl_net_dialer_websocket_job(void *data, const Efl_Event *ev EINA_UNUSED)
740 Eo *o = data; 740 Eo *o = data;
741 Efl_Net_Dialer_Websocket_Data *pd = efl_data_scope_get(o, MY_CLASS); 741 Efl_Net_Dialer_Websocket_Data *pd = efl_data_scope_get(o, MY_CLASS);
742 742
743 pd->job = NULL;
744
745 efl_ref(o); 743 efl_ref(o);
746 744
747 if (efl_io_reader_can_read_get(pd->http)) 745 if (efl_io_reader_can_read_get(pd->http))
@@ -767,6 +765,7 @@ _efl_net_dialer_websocket_job_schedule(Eo *o, Efl_Net_Dialer_Websocket_Data *pd)
767 if (!loop) return; 765 if (!loop) return;
768 efl_future_use(&pd->job, efl_loop_job(loop, o)); 766 efl_future_use(&pd->job, efl_loop_job(loop, o));
769 efl_future_then(pd->job, _efl_net_dialer_websocket_job, NULL, NULL, o); 767 efl_future_then(pd->job, _efl_net_dialer_websocket_job, NULL, NULL, o);
768 efl_future_link(o, pd->job);
770} 769}
771 770
772static void 771static void
@@ -962,18 +961,9 @@ _efl_net_dialer_websocket_efl_object_destructor(Eo *o, Efl_Net_Dialer_Websocket_
962 961
963 efl_event_callback_array_del(pd->http, _efl_net_dialer_websocket_http_cbs(), o); 962 efl_event_callback_array_del(pd->http, _efl_net_dialer_websocket_http_cbs(), o);
964 963
965 if (pd->close_timeout)
966 efl_future_cancel(pd->close_timeout);
967
968 efl_del(pd->http); 964 efl_del(pd->http);
969 pd->http = NULL; 965 pd->http = NULL;
970 966
971 if (pd->job)
972 {
973 efl_future_cancel(pd->job);
974 pd->job = NULL;
975 }
976
977 efl_destructor(efl_super(o, MY_CLASS)); 967 efl_destructor(efl_super(o, MY_CLASS));
978 968
979 eina_stringshare_replace(&pd->address_dial, NULL); 969 eina_stringshare_replace(&pd->address_dial, NULL);
@@ -1511,6 +1501,7 @@ _efl_net_dialer_websocket_close_request(Eo *o, Efl_Net_Dialer_Websocket_Data *pd
1511 1501
1512 efl_future_use(&pd->close_timeout, efl_loop_timeout(efl_loop_user_loop_get(o), 2.0, o)); 1502 efl_future_use(&pd->close_timeout, efl_loop_timeout(efl_loop_user_loop_get(o), 2.0, o));
1513 efl_future_then(pd->close_timeout, _efl_net_dialer_websocket_close_request_timeout, NULL, NULL, o); 1503 efl_future_then(pd->close_timeout, _efl_net_dialer_websocket_close_request_timeout, NULL, NULL, o);
1504 efl_future_link(o, pd->close_timeout);
1514 1505
1515 efl_io_writer_can_write_set(o, EINA_FALSE); 1506 efl_io_writer_can_write_set(o, EINA_FALSE);
1516 1507