summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorGuilherme Iscaro <iscaro@profusion.mobi>2017-08-30 17:24:27 -0300
committerGuilherme Iscaro <iscaro@profusion.mobi>2017-09-04 10:24:00 -0300
commitec27ceac2769165e0454d3bf7fce3df1d8b5b8cf (patch)
tree5736f7c28feb4441a26e3f0dccccc6d5816b0329 /src/lib/ecore_con
parent22cee38239912d87467844ded59589c9fed319d4 (diff)
efl_net: Use the new Eina_Future API.
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/ecore_con_legacy.c75
-rw-r--r--src/lib/ecore_con/efl_net_dialer_http.c45
-rw-r--r--src/lib/ecore_con/efl_net_dialer_ssl.c39
-rw-r--r--src/lib/ecore_con/efl_net_dialer_tcp.c39
-rw-r--r--src/lib/ecore_con/efl_net_dialer_udp.c39
-rw-r--r--src/lib/ecore_con/efl_net_dialer_unix.c43
-rw-r--r--src/lib/ecore_con/efl_net_dialer_websocket.c34
-rw-r--r--src/lib/ecore_con/efl_net_server_windows.c20
8 files changed, 168 insertions, 166 deletions
diff --git a/src/lib/ecore_con/ecore_con_legacy.c b/src/lib/ecore_con/ecore_con_legacy.c
index 1cb007f8b1..ade01e222f 100644
--- a/src/lib/ecore_con/ecore_con_legacy.c
+++ b/src/lib/ecore_con/ecore_con_legacy.c
@@ -31,7 +31,7 @@ struct _Ecore_Con_Server
31 Eo *dialer; 31 Eo *dialer;
32 Eo *server; 32 Eo *server;
33 struct { 33 struct {
34 Efl_Future *job; 34 Eina_Future *job;
35 Eina_Binbuf *pending_send; /* until job is fulfilled, no dialer exists, 35 Eina_Binbuf *pending_send; /* until job is fulfilled, no dialer exists,
36 * this binbuf allows immediate 36 * this binbuf allows immediate
37 * ecore_con_server_send() in that situation */ 37 * ecore_con_server_send() in that situation */
@@ -71,7 +71,7 @@ struct _Ecore_Con_Client
71 const void *data; 71 const void *data;
72 Eina_Stringshare *ip; 72 Eina_Stringshare *ip;
73 struct { 73 struct {
74 Efl_Future *job; 74 Eina_Future *job;
75 Eo *ctx; 75 Eo *ctx;
76 Eina_Bool upgrading; 76 Eina_Bool upgrading;
77 } ssl; 77 } ssl;
@@ -289,7 +289,7 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
289 cl->socket = NULL; 289 cl->socket = NULL;
290 } 290 }
291 291
292 if (cl->ssl.job) efl_future_cancel(cl->ssl.job); 292 if (cl->ssl.job) eina_future_cancel(cl->ssl.job);
293 293
294 if (cl->ssl.ctx) 294 if (cl->ssl.ctx)
295 { 295 {
@@ -813,8 +813,9 @@ EFL_CALLBACKS_ARRAY_DEFINE(_ecore_con_client_socket_ssl_cbs,
813 { EFL_NET_SOCKET_SSL_EVENT_SSL_READY, _ecore_con_client_socket_ssl_ready }, 813 { EFL_NET_SOCKET_SSL_EVENT_SSL_READY, _ecore_con_client_socket_ssl_ready },
814 { EFL_NET_SOCKET_SSL_EVENT_SSL_ERROR, _ecore_con_client_socket_ssl_error }); 814 { EFL_NET_SOCKET_SSL_EVENT_SSL_ERROR, _ecore_con_client_socket_ssl_error });
815 815
816static void 816static Eina_Value
817_ecore_con_client_ssl_upgrade_job(void *data, const Efl_Event *event EINA_UNUSED) 817_ecore_con_client_ssl_upgrade_job(void *data, const Eina_Value v,
818 const Eina_Future *dead EINA_UNUSED)
818{ 819{
819 Ecore_Con_Client *cl = data; 820 Ecore_Con_Client *cl = data;
820 Eo *loop = ecore_main_loop_get(); 821 Eo *loop = ecore_main_loop_get();
@@ -822,6 +823,9 @@ _ecore_con_client_ssl_upgrade_job(void *data, const Efl_Event *event EINA_UNUSED
822 Eo *socket; 823 Eo *socket;
823 Eo *tcp_socket; 824 Eo *tcp_socket;
824 825
826 //Canceled
827 if (v.type == EINA_VALUE_TYPE_ERROR) return v;
828
825 tcp_socket = cl->socket; 829 tcp_socket = cl->socket;
826 cl->socket = NULL; /* take it, will be wrapped */ 830 cl->socket = NULL; /* take it, will be wrapped */
827 831
@@ -852,7 +856,7 @@ _ecore_con_client_ssl_upgrade_job(void *data, const Efl_Event *event EINA_UNUSED
852 efl_io_buffered_stream_inner_io_get(cl->socket), 856 efl_io_buffered_stream_inner_io_get(cl->socket),
853 cl->ssl.ctx, 857 cl->ssl.ctx,
854 tcp_socket); 858 tcp_socket);
855 return; 859 return v;
856 860
857 error_socket: 861 error_socket:
858 efl_del(inner_socket); 862 efl_del(inner_socket);
@@ -860,10 +864,18 @@ _ecore_con_client_ssl_upgrade_job(void *data, const Efl_Event *event EINA_UNUSED
860 cl->socket = tcp_socket; /* put it back */ 864 cl->socket = tcp_socket; /* put it back */
861 if (_ecore_con_post_event_client_error(cl, "Couldn't finish SSL setup")) 865 if (_ecore_con_post_event_client_error(cl, "Couldn't finish SSL setup"))
862 _ecore_con_post_event_client_del(cl); 866 _ecore_con_post_event_client_del(cl);
867 return v;
863} 868}
864 869
865static Eo * _ecore_con_server_ssl_ctx_create(const Ecore_Con_Server *svr); 870static Eo * _ecore_con_server_ssl_ctx_create(const Ecore_Con_Server *svr);
866 871
872static void
873_ecore_con_server_job_schedule(Ecore_Con_Server *svr, Eo *loop,
874 Eina_Future_Cb cb)
875{
876 eina_future_then(efl_loop_Eina_FutureXXX_job(loop), cb, svr, &svr->ssl.job);
877}
878
867EAPI Eina_Bool 879EAPI Eina_Bool
868ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type compl_type) 880ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type compl_type)
869{ 881{
@@ -905,8 +917,9 @@ ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type compl_type)
905 917
906 cl->ssl.upgrading = EINA_TRUE; 918 cl->ssl.upgrading = EINA_TRUE;
907 cl->ssl.ctx = ssl_ctx; 919 cl->ssl.ctx = ssl_ctx;
908 efl_future_use(&cl->ssl.job, efl_loop_job(efl_loop_get(cl->socket), cl)); 920
909 efl_future_then(cl->ssl.job, _ecore_con_client_ssl_upgrade_job, NULL, NULL, cl); 921 eina_future_then(efl_loop_Eina_FutureXXX_job(efl_loop_get(cl->socket)),
922 _ecore_con_client_ssl_upgrade_job, cl, &cl->ssl.job);
910 923
911 DBG("cl=%p SSL upgrading from %#x to type=%#x", cl, svr->type, compl_type); 924 DBG("cl=%p SSL upgrading from %#x to type=%#x", cl, svr->type, compl_type);
912 925
@@ -981,7 +994,7 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
981 svr->ssl.clients_ctx = NULL; 994 svr->ssl.clients_ctx = NULL;
982 } 995 }
983 996
984 if (svr->ssl.job) efl_future_cancel(svr->ssl.job); 997 if (svr->ssl.job) eina_future_cancel(svr->ssl.job);
985 998
986 if (svr->ssl.pending_send) 999 if (svr->ssl.pending_send)
987 { 1000 {
@@ -1591,8 +1604,9 @@ _ecore_con_server_ssl_ctx_create(const Ecore_Con_Server *svr)
1591 efl_net_ssl_context_setup(efl_added, cipher, EINA_FALSE)); 1604 efl_net_ssl_context_setup(efl_added, cipher, EINA_FALSE));
1592} 1605}
1593 1606
1594static void 1607static Eina_Value
1595_ecore_con_server_server_ssl_job(void *data, const Efl_Event *event EINA_UNUSED) 1608_ecore_con_server_server_ssl_job(void *data, const Eina_Value v,
1609 const Eina_Future *dead EINA_UNUSED)
1596{ 1610{
1597 Ecore_Con_Server *svr = data; 1611 Ecore_Con_Server *svr = data;
1598 Eo *loop = ecore_main_loop_get(); 1612 Eo *loop = ecore_main_loop_get();
@@ -1600,6 +1614,8 @@ _ecore_con_server_server_ssl_job(void *data, const Efl_Event *event EINA_UNUSED)
1600 Eo *inner_server; 1614 Eo *inner_server;
1601 Eo *server; 1615 Eo *server;
1602 1616
1617 if (v.type == EINA_VALUE_TYPE_ERROR) return v;
1618
1603 ssl_ctx = _ecore_con_server_ssl_ctx_create(svr); 1619 ssl_ctx = _ecore_con_server_ssl_ctx_create(svr);
1604 EINA_SAFETY_ON_NULL_GOTO(ssl_ctx, error_ssl_ctx); 1620 EINA_SAFETY_ON_NULL_GOTO(ssl_ctx, error_ssl_ctx);
1605 1621
@@ -1624,12 +1640,12 @@ _ecore_con_server_server_ssl_job(void *data, const Efl_Event *event EINA_UNUSED)
1624 efl_net_server_simple_inner_server_get(svr->server), 1640 efl_net_server_simple_inner_server_get(svr->server),
1625 efl_net_server_ssl_context_get(efl_net_server_simple_inner_server_get(svr->server))); 1641 efl_net_server_ssl_context_get(efl_net_server_simple_inner_server_get(svr->server)));
1626 1642
1627 return; 1643 return v;
1628 1644
1629 error_serve: 1645 error_serve:
1630 if (_ecore_con_post_event_server_error(svr, "Couldn't serve using SSL")) 1646 if (_ecore_con_post_event_server_error(svr, "Couldn't serve using SSL"))
1631 _ecore_con_post_event_server_del(svr); 1647 _ecore_con_post_event_server_del(svr);
1632 return; 1648 return v;
1633 1649
1634 error_server: 1650 error_server:
1635 efl_del(inner_server); 1651 efl_del(inner_server);
@@ -1638,6 +1654,7 @@ _ecore_con_server_server_ssl_job(void *data, const Efl_Event *event EINA_UNUSED)
1638 error_ssl_ctx: 1654 error_ssl_ctx:
1639 if (_ecore_con_post_event_server_error(svr, "Couldn't finish SSL setup")) 1655 if (_ecore_con_post_event_server_error(svr, "Couldn't finish SSL setup"))
1640 _ecore_con_post_event_server_del(svr); 1656 _ecore_con_post_event_server_del(svr);
1657 return v;
1641} 1658}
1642 1659
1643/** 1660/**
@@ -1725,8 +1742,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
1725 * > against loaded certificates. 1742 * > against loaded certificates.
1726 */ 1743 */
1727 svr->ssl.upgrade_type = compl_type; 1744 svr->ssl.upgrade_type = compl_type;
1728 efl_future_use(&svr->ssl.job, efl_loop_job(loop, svr)); 1745 _ecore_con_server_job_schedule(svr, loop, _ecore_con_server_server_ssl_job);
1729 efl_future_then(svr->ssl.job, _ecore_con_server_server_ssl_job, NULL, NULL, svr);
1730 return svr; 1746 return svr;
1731 } 1747 }
1732 1748
@@ -1921,8 +1937,9 @@ _ecore_con_server_dialer_set(Ecore_Con_Server *svr, Eo *dialer)
1921 return EINA_TRUE; 1937 return EINA_TRUE;
1922} 1938}
1923 1939
1924static void 1940static Eina_Value
1925_ecore_con_server_dialer_ssl_job(void *data, const Efl_Event *event EINA_UNUSED) 1941_ecore_con_server_dialer_ssl_job(void *data, const Eina_Value v,
1942 const Eina_Future *dead EINA_UNUSED)
1926{ 1943{
1927 Ecore_Con_Server *svr = data; 1944 Ecore_Con_Server *svr = data;
1928 Eo *loop = ecore_main_loop_get(); 1945 Eo *loop = ecore_main_loop_get();
@@ -1993,12 +2010,12 @@ _ecore_con_server_dialer_ssl_job(void *data, const Efl_Event *event EINA_UNUSED)
1993 svr->ssl.pending_send = NULL; 2010 svr->ssl.pending_send = NULL;
1994 } 2011 }
1995 2012
1996 return; 2013 return v;
1997 2014
1998 error_dial: 2015 error_dial:
1999 if (_ecore_con_post_event_server_error(svr, "Couldn't dial using SSL")) 2016 if (_ecore_con_post_event_server_error(svr, "Couldn't dial using SSL"))
2000 _ecore_con_post_event_server_del(svr); 2017 _ecore_con_post_event_server_del(svr);
2001 return; 2018 return v;
2002 2019
2003 error_dialer: 2020 error_dialer:
2004 efl_del(inner_dialer); 2021 efl_del(inner_dialer);
@@ -2007,10 +2024,12 @@ _ecore_con_server_dialer_ssl_job(void *data, const Efl_Event *event EINA_UNUSED)
2007 error_ssl_ctx: 2024 error_ssl_ctx:
2008 if (_ecore_con_post_event_server_error(svr, "Couldn't finish SSL setup")) 2025 if (_ecore_con_post_event_server_error(svr, "Couldn't finish SSL setup"))
2009 _ecore_con_post_event_server_del(svr); 2026 _ecore_con_post_event_server_del(svr);
2027 return v;
2010} 2028}
2011 2029
2012static void 2030static Eina_Value
2013_ecore_con_server_dialer_ssl_upgrade_job(void *data, const Efl_Event *event EINA_UNUSED) 2031_ecore_con_server_dialer_ssl_upgrade_job(void *data, const Eina_Value v,
2032 const Eina_Future *dead EINA_UNUSED)
2014{ 2033{
2015 Ecore_Con_Server *svr = data; 2034 Ecore_Con_Server *svr = data;
2016 Eo *loop = ecore_main_loop_get(); 2035 Eo *loop = ecore_main_loop_get();
@@ -2022,6 +2041,9 @@ _ecore_con_server_dialer_ssl_upgrade_job(void *data, const Efl_Event *event EINA
2022 Efl_Net_Ssl_Verify_Mode verify_mode = EFL_NET_SSL_VERIFY_MODE_NONE; /* was the default */ 2041 Efl_Net_Ssl_Verify_Mode verify_mode = EFL_NET_SSL_VERIFY_MODE_NONE; /* was the default */
2023 Ecore_Con_Type ssl_type = svr->ssl.upgrade_type & ECORE_CON_SSL; 2042 Ecore_Con_Type ssl_type = svr->ssl.upgrade_type & ECORE_CON_SSL;
2024 2043
2044 //Canceled
2045 if (v.type == EINA_VALUE_TYPE_ERROR) return v;
2046
2025 if (ssl_type & ECORE_CON_USE_MIXED) 2047 if (ssl_type & ECORE_CON_USE_MIXED)
2026 cipher = EFL_NET_SSL_CIPHER_AUTO; 2048 cipher = EFL_NET_SSL_CIPHER_AUTO;
2027 else if (ssl_type & ECORE_CON_USE_TLS) 2049 else if (ssl_type & ECORE_CON_USE_TLS)
@@ -2078,7 +2100,7 @@ _ecore_con_server_dialer_ssl_upgrade_job(void *data, const Efl_Event *event EINA
2078 efl_io_buffered_stream_inner_io_get(svr->dialer), 2100 efl_io_buffered_stream_inner_io_get(svr->dialer),
2079 efl_net_dialer_ssl_context_get(efl_io_buffered_stream_inner_io_get(svr->dialer)), 2101 efl_net_dialer_ssl_context_get(efl_io_buffered_stream_inner_io_get(svr->dialer)),
2080 tcp_dialer); 2102 tcp_dialer);
2081 return; 2103 return v;
2082 2104
2083 error_dialer: 2105 error_dialer:
2084 efl_del(inner_dialer); 2106 efl_del(inner_dialer);
@@ -2088,6 +2110,7 @@ _ecore_con_server_dialer_ssl_upgrade_job(void *data, const Efl_Event *event EINA
2088 error_ssl_ctx: 2110 error_ssl_ctx:
2089 if (_ecore_con_post_event_server_error(svr, "Couldn't finish SSL setup")) 2111 if (_ecore_con_post_event_server_error(svr, "Couldn't finish SSL setup"))
2090 _ecore_con_post_event_server_del(svr); 2112 _ecore_con_post_event_server_del(svr);
2113 return v;
2091} 2114}
2092 2115
2093/** 2116/**
@@ -2174,8 +2197,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
2174 * > has started to enable verification of certificates 2197 * > has started to enable verification of certificates
2175 * > against loaded certificates. 2198 * > against loaded certificates.
2176 */ 2199 */
2177 efl_future_use(&svr->ssl.job, efl_loop_job(loop, svr)); 2200 _ecore_con_server_job_schedule(svr, loop, _ecore_con_server_dialer_ssl_job);
2178 efl_future_then(svr->ssl.job, _ecore_con_server_dialer_ssl_job, NULL, NULL, svr);
2179 return svr; 2201 return svr;
2180 } 2202 }
2181 2203
@@ -2535,8 +2557,9 @@ ecore_con_ssl_server_upgrade(Ecore_Con_Server *svr, Ecore_Con_Type compl_type)
2535 2557
2536 svr->ssl.upgrading = EINA_TRUE; 2558 svr->ssl.upgrading = EINA_TRUE;
2537 svr->ssl.upgrade_type = compl_type; 2559 svr->ssl.upgrade_type = compl_type;
2538 efl_future_use(&svr->ssl.job, efl_loop_job(efl_loop_get(svr->dialer), svr)); 2560
2539 efl_future_then(svr->ssl.job, _ecore_con_server_dialer_ssl_upgrade_job, NULL, NULL, svr); 2561 _ecore_con_server_job_schedule(svr, efl_loop_get(svr->dialer),
2562 _ecore_con_server_dialer_ssl_upgrade_job);
2540 2563
2541 DBG("svr=%p SSL upgrading from %#x to type=%#x", svr, svr->type, compl_type); 2564 DBG("svr=%p SSL upgrading from %#x to type=%#x", svr, svr->type, compl_type);
2542 2565
diff --git a/src/lib/ecore_con/efl_net_dialer_http.c b/src/lib/ecore_con/efl_net_dialer_http.c
index 064c000ace..4d64a20aab 100644
--- a/src/lib/ecore_con/efl_net_dialer_http.c
+++ b/src/lib/ecore_con/efl_net_dialer_http.c
@@ -207,7 +207,7 @@ typedef struct
207 Eina_Bool verify_peer; 207 Eina_Bool verify_peer;
208 Eina_Bool verify_hostname; 208 Eina_Bool verify_hostname;
209 } ssl; 209 } ssl;
210 Efl_Future *pending_close; 210 Eina_Future *pending_close;
211 unsigned int in_curl_callback; 211 unsigned int in_curl_callback;
212 SOCKET fd; 212 SOCKET fd;
213 Eina_Error error; 213 Eina_Error error;
@@ -796,27 +796,28 @@ _efl_net_dialer_http_curl_safe_begin(Eo *o, Efl_Net_Dialer_Http_Data *pd)
796 return pd->easy; 796 return pd->easy;
797} 797}
798 798
799static void 799static Eina_Value
800_efl_net_dialer_http_curl_cleanup(void *data, const Efl_Event *ev EINA_UNUSED) 800_efl_net_dialer_http_curl_cleanup(void *data, const Eina_Value v)
801{ 801{
802 CURL *easy = data; 802 CURL *easy = data;
803 DBG("cleanup curl=%p", easy); 803 DBG("cleanup curl=%p", easy);
804 curl_easy_cleanup(easy); 804 curl_easy_cleanup(easy);
805 return v;
805} 806}
806 807
807static void 808static Eina_Value
808_efl_net_dialer_http_curl_cleanup_error(void *data, const Efl_Event *ev) 809_efl_net_dialer_http_curl_cleanup_error(void *data, const Eina_Error err)
809{ 810{
810 Efl_Future_Event_Failure *failure = ev->info;
811 CURL *easy = data; 811 CURL *easy = data;
812 DBG("cleanup curl=%p, promise error=%d '%s'", easy, failure->error, eina_error_msg_get(failure->error)); 812 DBG("cleanup curl=%p, promise error=%d '%s'", easy, err, eina_error_msg_get(err));
813 curl_easy_cleanup(easy); 813 curl_easy_cleanup(easy);
814 return EINA_VALUE_EMPTY;
814} 815}
815 816
816static void 817static void
817_efl_net_dialer_http_curl_safe_end(Eo *o, Efl_Net_Dialer_Http_Data *pd, CURL *easy) 818_efl_net_dialer_http_curl_safe_end(Eo *o, Efl_Net_Dialer_Http_Data *pd, CURL *easy)
818{ 819{
819 Efl_Future *f; 820 Eina_Future *f;
820 int refs; 821 int refs;
821 822
822 refs = efl_ref_get(o); 823 refs = efl_ref_get(o);
@@ -828,7 +829,7 @@ _efl_net_dialer_http_curl_safe_end(Eo *o, Efl_Net_Dialer_Http_Data *pd, CURL *ea
828 } 829 }
829 830
830 if (pd->pending_close) 831 if (pd->pending_close)
831 efl_future_cancel(pd->pending_close); 832 eina_future_cancel(pd->pending_close);
832 833
833 if (!pd->easy) 834 if (!pd->easy)
834 { 835 {
@@ -861,12 +862,10 @@ _efl_net_dialer_http_curl_safe_end(Eo *o, Efl_Net_Dialer_Http_Data *pd, CURL *ea
861 /* object deleted from CURL callback, CURL* easy was 862 /* object deleted from CURL callback, CURL* easy was
862 * dissociated and we must delete it ourselves. 863 * dissociated and we must delete it ourselves.
863 */ 864 */
864 f = efl_loop_job(ecore_main_loop_get(), easy); 865 f = efl_loop_Eina_FutureXXX_job(ecore_main_loop_get());
865 efl_future_then(f, 866 eina_future_then_from_desc(f, eina_future_cb_easy(.success = _efl_net_dialer_http_curl_cleanup,
866 _efl_net_dialer_http_curl_cleanup, 867 .error = _efl_net_dialer_http_curl_cleanup_error,
867 _efl_net_dialer_http_curl_cleanup_error, 868 .data = easy));
868 NULL,
869 easy);
870 DBG("dialer=%p deleted from CURL callback, cleanup curl from job=%p.", o, f); 869 DBG("dialer=%p deleted from CURL callback, cleanup curl from job=%p.", o, f);
871} 870}
872 871
@@ -1144,7 +1143,7 @@ _efl_net_dialer_http_efl_object_destructor(Eo *o, Efl_Net_Dialer_Http_Data *pd)
1144 } 1143 }
1145 else if (pd->pending_close) 1144 else if (pd->pending_close)
1146 { 1145 {
1147 efl_future_cancel(pd->pending_close); 1146 eina_future_cancel(pd->pending_close);
1148 efl_event_freeze(o); 1147 efl_event_freeze(o);
1149 efl_io_closer_close(o); 1148 efl_io_closer_close(o);
1150 efl_event_thaw(o); 1149 efl_event_thaw(o);
@@ -1704,7 +1703,7 @@ _efl_net_dialer_http_efl_io_writer_can_write_set(Eo *o, Efl_Net_Dialer_Http_Data
1704 efl_event_callback_call(o, EFL_IO_WRITER_EVENT_CAN_WRITE_CHANGED, NULL); 1703 efl_event_callback_call(o, EFL_IO_WRITER_EVENT_CAN_WRITE_CHANGED, NULL);
1705} 1704}
1706 1705
1707static void _efl_net_dialer_http_pending_close(void *data, const Efl_Event *ev); 1706static Eina_Value _efl_net_dialer_http_pending_close(Eo *o, Eina_Value value);
1708 1707
1709EOLIAN static Eina_Error 1708EOLIAN static Eina_Error
1710_efl_net_dialer_http_efl_io_closer_close(Eo *o, Efl_Net_Dialer_Http_Data *pd) 1709_efl_net_dialer_http_efl_io_closer_close(Eo *o, Efl_Net_Dialer_Http_Data *pd)
@@ -1719,8 +1718,9 @@ _efl_net_dialer_http_efl_io_closer_close(Eo *o, Efl_Net_Dialer_Http_Data *pd)
1719 { 1718 {
1720 if ((!pd->pending_close) && (pd->easy)) 1719 if ((!pd->pending_close) && (pd->easy))
1721 { 1720 {
1722 efl_future_use(&pd->pending_close, efl_loop_job(efl_loop_get(o), o)); 1721 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_job(efl_loop_get(o)),
1723 efl_future_then(pd->pending_close, _efl_net_dialer_http_pending_close, NULL, NULL, o); 1722 .success = _efl_net_dialer_http_pending_close,
1723 .storage = &pd->pending_close);
1724 DBG("dialer=%p closed from CURL callback, schedule close job=%p", o, pd->pending_close); 1724 DBG("dialer=%p closed from CURL callback, schedule close job=%p", o, pd->pending_close);
1725 } 1725 }
1726 return 0; 1726 return 0;
@@ -1751,14 +1751,13 @@ _efl_net_dialer_http_efl_io_closer_close(Eo *o, Efl_Net_Dialer_Http_Data *pd)
1751 return err; 1751 return err;
1752} 1752}
1753 1753
1754static void 1754static Eina_Value
1755_efl_net_dialer_http_pending_close(void *data, const Efl_Event *ev EINA_UNUSED) 1755_efl_net_dialer_http_pending_close(Eo *o, const Eina_Value value EINA_UNUSED)
1756{ 1756{
1757 Eo *o = data;
1758 Efl_Net_Dialer_Http_Data *pd = efl_data_scope_get(o, MY_CLASS); 1757 Efl_Net_Dialer_Http_Data *pd = efl_data_scope_get(o, MY_CLASS);
1759 1758
1760 pd->pending_close = NULL; /* XXX TODO this should be NULL-ified by efl_promise before calling this function */
1761 _efl_net_dialer_http_efl_io_closer_close(o, pd); 1759 _efl_net_dialer_http_efl_io_closer_close(o, pd);
1760 return value;
1762} 1761}
1763 1762
1764EOLIAN static Eina_Bool 1763EOLIAN static Eina_Bool
diff --git a/src/lib/ecore_con/efl_net_dialer_ssl.c b/src/lib/ecore_con/efl_net_dialer_ssl.c
index d873434756..6bdae468c8 100644
--- a/src/lib/ecore_con/efl_net_dialer_ssl.c
+++ b/src/lib/ecore_con/efl_net_dialer_ssl.c
@@ -34,7 +34,7 @@ typedef struct _Efl_Net_Dialer_Ssl_Data
34{ 34{
35 Eo *sock; 35 Eo *sock;
36 Eo *ssl_ctx; 36 Eo *ssl_ctx;
37 Efl_Future *connect_timeout; 37 Eina_Future *connect_timeout;
38 Eina_Bool connected; 38 Eina_Bool connected;
39} Efl_Net_Dialer_Ssl_Data; 39} Efl_Net_Dialer_Ssl_Data;
40 40
@@ -136,16 +136,24 @@ _efl_net_dialer_ssl_ssl_context_get(Eo *o EINA_UNUSED, Efl_Net_Dialer_Ssl_Data *
136 return pd->ssl_ctx; 136 return pd->ssl_ctx;
137} 137}
138 138
139static void 139static Eina_Value
140_efl_net_dialer_ssl_connect_timeout(void *data, const Efl_Event *ev EINA_UNUSED) 140_efl_net_dialer_ssl_connect_timeout(Eo *o, const Eina_Value v)
141{ 141{
142 Eo *o = data;
143 Eina_Error err = ETIMEDOUT; 142 Eina_Error err = ETIMEDOUT;
144 143
145 efl_ref(o); 144 efl_ref(o);
146 efl_io_reader_eos_set(o, EINA_TRUE); 145 efl_io_reader_eos_set(o, EINA_TRUE);
147 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err); 146 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err);
148 efl_unref(o); 147 efl_unref(o);
148 return v;
149}
150
151static void
152_timeout_schedule(Eo *o, Efl_Net_Dialer_Ssl_Data *pd, double timeout)
153{
154 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_timeout(efl_loop_get(o), timeout),
155 .success = _efl_net_dialer_ssl_connect_timeout,
156 .storage = &pd->connect_timeout);
149} 157}
150 158
151EOLIAN static Eina_Error 159EOLIAN static Eina_Error
@@ -157,16 +165,10 @@ _efl_net_dialer_ssl_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Ssl_Data *pd, cons
157 EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_net_dialer_connected_get(o), EISCONN); 165 EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_net_dialer_connected_get(o), EISCONN);
158 EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(o), EBADF); 166 EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(o), EBADF);
159 167
160 if (pd->connect_timeout) 168 if (pd->connect_timeout) eina_future_cancel(pd->connect_timeout);
161 efl_future_cancel(pd->connect_timeout);
162 169
163 timeout = efl_net_dialer_timeout_dial_get(pd->sock); 170 timeout = efl_net_dialer_timeout_dial_get(pd->sock);
164 if (timeout > 0.0) 171 if (timeout > 0.0) _timeout_schedule(o, pd, timeout);
165 {
166 efl_future_use(&pd->connect_timeout, efl_loop_timeout(efl_loop_get(o), timeout, o));
167 efl_future_then(pd->connect_timeout, _efl_net_dialer_ssl_connect_timeout, NULL, NULL, o);
168 efl_future_link(o, pd->connect_timeout);
169 }
170 172
171 return efl_net_dialer_dial(pd->sock, address); 173 return efl_net_dialer_dial(pd->sock, address);
172} 174}
@@ -190,18 +192,13 @@ _efl_net_dialer_ssl_efl_net_dialer_proxy_get(Eo *o EINA_UNUSED, Efl_Net_Dialer_S
190} 192}
191 193
192EOLIAN static void 194EOLIAN static void
193_efl_net_dialer_ssl_efl_net_dialer_timeout_dial_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Ssl_Data *pd, double seconds) 195_efl_net_dialer_ssl_efl_net_dialer_timeout_dial_set(Eo *o, Efl_Net_Dialer_Ssl_Data *pd, double seconds)
194{ 196{
195 efl_net_dialer_timeout_dial_set(pd->sock, seconds); 197 efl_net_dialer_timeout_dial_set(pd->sock, seconds);
196 198
197 if (pd->connect_timeout) 199 if (pd->connect_timeout) eina_future_cancel(pd->connect_timeout);
198 efl_future_cancel(pd->connect_timeout);
199 200
200 if ((seconds > 0.0) && (!pd->connected)) 201 if ((seconds > 0.0) && (!pd->connected)) _timeout_schedule(o, pd, seconds);
201 {
202 efl_future_use(&pd->connect_timeout, efl_loop_timeout(efl_loop_get(o), seconds, o));
203 efl_future_then(pd->connect_timeout, _efl_net_dialer_ssl_connect_timeout, NULL, NULL, o);
204 }
205} 202}
206 203
207EOLIAN static double 204EOLIAN static double
@@ -214,7 +211,7 @@ EOLIAN static void
214_efl_net_dialer_ssl_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Ssl_Data *pd, Eina_Bool connected) 211_efl_net_dialer_ssl_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Ssl_Data *pd, Eina_Bool connected)
215{ 212{
216 if (pd->connect_timeout) 213 if (pd->connect_timeout)
217 efl_future_cancel(pd->connect_timeout); 214 eina_future_cancel(pd->connect_timeout);
218 if (pd->connected == connected) return; 215 if (pd->connected == connected) return;
219 pd->connected = connected; 216 pd->connected = connected;
220 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL); 217 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL);
diff --git a/src/lib/ecore_con/efl_net_dialer_tcp.c b/src/lib/ecore_con/efl_net_dialer_tcp.c
index 8806cc33bb..a9d87cfa6d 100644
--- a/src/lib/ecore_con/efl_net_dialer_tcp.c
+++ b/src/lib/ecore_con/efl_net_dialer_tcp.c
@@ -34,7 +34,7 @@ typedef struct _Efl_Net_Dialer_Tcp_Data
34{ 34{
35 struct { 35 struct {
36 Ecore_Thread *thread; 36 Ecore_Thread *thread;
37 Efl_Future *timeout; 37 Eina_Future *timeout;
38 } connect; 38 } connect;
39 Eina_Stringshare *address_dial; 39 Eina_Stringshare *address_dial;
40 Eina_Stringshare *proxy; 40 Eina_Stringshare *proxy;
@@ -75,10 +75,9 @@ _efl_net_dialer_tcp_efl_object_destructor(Eo *o, Efl_Net_Dialer_Tcp_Data *pd)
75 eina_stringshare_replace(&pd->proxy, NULL); 75 eina_stringshare_replace(&pd->proxy, NULL);
76} 76}
77 77
78static void 78static Eina_Value
79_efl_net_dialer_tcp_connect_timeout(void *data, const Efl_Event *ev EINA_UNUSED) 79_efl_net_dialer_tcp_connect_timeout(Eo *o, const Eina_Value v)
80{ 80{
81 Eo *o = data;
82 Efl_Net_Dialer_Tcp_Data *pd = efl_data_scope_get(o, MY_CLASS); 81 Efl_Net_Dialer_Tcp_Data *pd = efl_data_scope_get(o, MY_CLASS);
83 Eina_Error err = ETIMEDOUT; 82 Eina_Error err = ETIMEDOUT;
84 83
@@ -92,6 +91,15 @@ _efl_net_dialer_tcp_connect_timeout(void *data, const Efl_Event *ev EINA_UNUSED)
92 efl_io_reader_eos_set(o, EINA_TRUE); 91 efl_io_reader_eos_set(o, EINA_TRUE);
93 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err); 92 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err);
94 efl_unref(o); 93 efl_unref(o);
94 return v;
95}
96
97static void
98_timeout_schedule(Eo *o, Efl_Net_Dialer_Tcp_Data *pd)
99{
100 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_timeout(efl_loop_get(o), pd->timeout_dial),
101 .success = _efl_net_dialer_tcp_connect_timeout,
102 .storage = &pd->connect.timeout);
95} 103}
96 104
97static void 105static void
@@ -179,14 +187,8 @@ _efl_net_dialer_tcp_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Tcp_Data *pd EINA_
179 187
180 efl_net_dialer_address_dial_set(o, address); 188 efl_net_dialer_address_dial_set(o, address);
181 189
182 if (pd->connect.timeout) 190 if (pd->connect.timeout) eina_future_cancel(pd->connect.timeout);
183 efl_future_cancel(pd->connect.timeout); 191 if (pd->timeout_dial > 0.0) _timeout_schedule(o, pd);
184 if (pd->timeout_dial > 0.0)
185 {
186 efl_future_use(&pd->connect.timeout, efl_loop_timeout(efl_loop_get(o), pd->timeout_dial, o));
187 efl_future_then(pd->connect.timeout, _efl_net_dialer_tcp_connect_timeout, NULL, NULL, o);
188 efl_future_link(o, pd->connect.timeout);
189 }
190 192
191 return 0; 193 return 0;
192} 194}
@@ -219,14 +221,8 @@ EOLIAN static void
219_efl_net_dialer_tcp_efl_net_dialer_timeout_dial_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Tcp_Data *pd, double seconds) 221_efl_net_dialer_tcp_efl_net_dialer_timeout_dial_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Tcp_Data *pd, double seconds)
220{ 222{
221 pd->timeout_dial = seconds; 223 pd->timeout_dial = seconds;
222 if (pd->connect.timeout) 224 if (pd->connect.timeout) eina_future_cancel(pd->connect.timeout);
223 efl_future_cancel(pd->connect.timeout); 225 if ((pd->timeout_dial > 0.0) && (pd->connect.thread)) _timeout_schedule(o, pd);
224
225 if ((pd->timeout_dial > 0.0) && (pd->connect.thread))
226 {
227 efl_future_use(&pd->connect.timeout, efl_loop_timeout(efl_loop_get(o), pd->timeout_dial, o));
228 efl_future_then(pd->connect.timeout, _efl_net_dialer_tcp_connect_timeout, NULL, NULL, o);
229 }
230} 226}
231 227
232EOLIAN static double 228EOLIAN static double
@@ -238,8 +234,7 @@ _efl_net_dialer_tcp_efl_net_dialer_timeout_dial_get(Eo *o EINA_UNUSED, Efl_Net_D
238EOLIAN static void 234EOLIAN static void
239_efl_net_dialer_tcp_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Tcp_Data *pd, Eina_Bool connected) 235_efl_net_dialer_tcp_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Tcp_Data *pd, Eina_Bool connected)
240{ 236{
241 if (pd->connect.timeout) 237 if (pd->connect.timeout) eina_future_cancel(pd->connect.timeout);
242 efl_future_cancel(pd->connect.timeout);
243 if (pd->connected == connected) return; 238 if (pd->connected == connected) return;
244 pd->connected = connected; 239 pd->connected = connected;
245 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL); 240 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL);
diff --git a/src/lib/ecore_con/efl_net_dialer_udp.c b/src/lib/ecore_con/efl_net_dialer_udp.c
index c85c770a20..bd2bf7e617 100644
--- a/src/lib/ecore_con/efl_net_dialer_udp.c
+++ b/src/lib/ecore_con/efl_net_dialer_udp.c
@@ -35,7 +35,7 @@ typedef struct _Efl_Net_Dialer_Udp_Data
35{ 35{
36 struct { 36 struct {
37 Ecore_Thread *thread; 37 Ecore_Thread *thread;
38 Efl_Future *timeout; 38 Eina_Future *timeout;
39 } resolver; 39 } resolver;
40 Eina_Stringshare *address_dial; 40 Eina_Stringshare *address_dial;
41 Eina_Bool connected; 41 Eina_Bool connected;
@@ -75,10 +75,9 @@ _efl_net_dialer_udp_efl_object_destructor(Eo *o, Efl_Net_Dialer_Udp_Data *pd)
75 eina_stringshare_replace(&pd->address_dial, NULL); 75 eina_stringshare_replace(&pd->address_dial, NULL);
76} 76}
77 77
78static void 78static Eina_Value
79_efl_net_dialer_udp_resolver_timeout(void *data, const Efl_Event *ev EINA_UNUSED) 79_efl_net_dialer_udp_resolver_timeout(Eo *o, const Eina_Value v)
80{ 80{
81 Eo *o = data;
82 Efl_Net_Dialer_Udp_Data *pd = efl_data_scope_get(o, MY_CLASS); 81 Efl_Net_Dialer_Udp_Data *pd = efl_data_scope_get(o, MY_CLASS);
83 Eina_Error err = ETIMEDOUT; 82 Eina_Error err = ETIMEDOUT;
84 83
@@ -92,6 +91,15 @@ _efl_net_dialer_udp_resolver_timeout(void *data, const Efl_Event *ev EINA_UNUSED
92 efl_io_reader_eos_set(o, EINA_TRUE); 91 efl_io_reader_eos_set(o, EINA_TRUE);
93 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err); 92 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err);
94 efl_unref(o); 93 efl_unref(o);
94 return v;
95}
96
97static void
98_timeout_schedule(Eo *o, Efl_Net_Dialer_Udp_Data *pd)
99{
100 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_timeout(efl_loop_get(o), pd->timeout_dial),
101 .success = _efl_net_dialer_udp_resolver_timeout,
102 .storage = &pd->resolver.timeout);
95} 103}
96 104
97static Eina_Error 105static Eina_Error
@@ -267,14 +275,8 @@ _efl_net_dialer_udp_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Udp_Data *pd EINA_
267 275
268 efl_net_dialer_address_dial_set(o, address); 276 efl_net_dialer_address_dial_set(o, address);
269 277
270 if (pd->resolver.timeout) 278 if (pd->resolver.timeout) eina_future_cancel(pd->resolver.timeout);
271 efl_future_cancel(pd->resolver.timeout); 279 if (pd->timeout_dial > 0.0) _timeout_schedule(o, pd);
272 if (pd->timeout_dial > 0.0)
273 {
274 efl_future_use(&pd->resolver.timeout, efl_loop_timeout(efl_loop_get(o), pd->timeout_dial, o));
275 efl_future_then(pd->resolver.timeout, _efl_net_dialer_udp_resolver_timeout, NULL, NULL, o);
276 efl_future_link(o, pd->resolver.timeout);
277 }
278 280
279 return 0; 281 return 0;
280} 282}
@@ -295,14 +297,8 @@ EOLIAN static void
295_efl_net_dialer_udp_efl_net_dialer_timeout_dial_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Udp_Data *pd, double seconds) 297_efl_net_dialer_udp_efl_net_dialer_timeout_dial_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Udp_Data *pd, double seconds)
296{ 298{
297 pd->timeout_dial = seconds; 299 pd->timeout_dial = seconds;
298 if (pd->resolver.timeout) 300 if (pd->resolver.timeout) eina_future_cancel(pd->resolver.timeout);
299 efl_future_cancel(pd->resolver.timeout); 301 if ((pd->timeout_dial > 0.0) && (pd->resolver.thread)) _timeout_schedule(o, pd);
300
301 if ((pd->timeout_dial > 0.0) && (pd->resolver.thread))
302 {
303 efl_future_use(&pd->resolver.timeout, efl_loop_timeout(efl_loop_get(o), pd->timeout_dial, o));
304 efl_future_then(pd->resolver.timeout, _efl_net_dialer_udp_resolver_timeout, NULL, NULL, o);
305 }
306} 302}
307 303
308EOLIAN static double 304EOLIAN static double
@@ -314,8 +310,7 @@ _efl_net_dialer_udp_efl_net_dialer_timeout_dial_get(Eo *o EINA_UNUSED, Efl_Net_D
314EOLIAN static void 310EOLIAN static void
315_efl_net_dialer_udp_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Udp_Data *pd, Eina_Bool connected) 311_efl_net_dialer_udp_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Udp_Data *pd, Eina_Bool connected)
316{ 312{
317 if (pd->resolver.timeout) 313 if (pd->resolver.timeout) eina_future_cancel(pd->resolver.timeout);
318 efl_future_cancel(pd->resolver.timeout);
319 if (pd->connected == connected) return; 314 if (pd->connected == connected) return;
320 pd->connected = connected; 315 pd->connected = connected;
321 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL); 316 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL);
diff --git a/src/lib/ecore_con/efl_net_dialer_unix.c b/src/lib/ecore_con/efl_net_dialer_unix.c
index 0493ff2f78..8a1db4bf5a 100644
--- a/src/lib/ecore_con/efl_net_dialer_unix.c
+++ b/src/lib/ecore_con/efl_net_dialer_unix.c
@@ -25,9 +25,8 @@ typedef struct _Efl_Net_Dialer_Unix_Data
25{ 25{
26 struct { 26 struct {
27 Ecore_Thread *thread; 27 Ecore_Thread *thread;
28 Efl_Future *timeout; 28 Eina_Future *timeout;
29 } connect; 29 } connect;
30 Efl_Future *connect_job;
31 Eina_Stringshare *address_dial; 30 Eina_Stringshare *address_dial;
32 Eina_Bool connected; 31 Eina_Bool connected;
33 double timeout_dial; 32 double timeout_dial;
@@ -65,10 +64,9 @@ _efl_net_dialer_unix_efl_object_destructor(Eo *o, Efl_Net_Dialer_Unix_Data *pd)
65 eina_stringshare_replace(&pd->address_dial, NULL); 64 eina_stringshare_replace(&pd->address_dial, NULL);
66} 65}
67 66
68static void 67static Eina_Value
69_efl_net_dialer_unix_connect_timeout(void *data, const Efl_Event *ev EINA_UNUSED) 68_efl_net_dialer_unix_connect_timeout(Eo *o, const Eina_Value v)
70{ 69{
71 Eo *o = data;
72 Efl_Net_Dialer_Unix_Data *pd = efl_data_scope_get(o, MY_CLASS); 70 Efl_Net_Dialer_Unix_Data *pd = efl_data_scope_get(o, MY_CLASS);
73 Eina_Error err = ETIMEDOUT; 71 Eina_Error err = ETIMEDOUT;
74 72
@@ -82,6 +80,7 @@ _efl_net_dialer_unix_connect_timeout(void *data, const Efl_Event *ev EINA_UNUSED
82 efl_io_reader_eos_set(o, EINA_TRUE); 80 efl_io_reader_eos_set(o, EINA_TRUE);
83 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err); 81 efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err);
84 efl_unref(o); 82 efl_unref(o);
83 return v;
85} 84}
86 85
87static void 86static void
@@ -121,8 +120,16 @@ _efl_net_dialer_unix_connected(void *data, const struct sockaddr *addr, socklen_
121 efl_unref(o); 120 efl_unref(o);
122} 121}
123 122
123static void
124_timeout_schedule(Eo *o, Efl_Net_Dialer_Unix_Data *pd)
125{
126 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_timeout(efl_loop_get(o), pd->timeout_dial),
127 .success = _efl_net_dialer_unix_connect_timeout,
128 .storage = &pd->connect.timeout);
129}
130
124EOLIAN static Eina_Error 131EOLIAN static Eina_Error
125_efl_net_dialer_unix_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Unix_Data *pd EINA_UNUSED, const char *address) 132_efl_net_dialer_unix_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Unix_Data *pd, const char *address)
126{ 133{
127 struct sockaddr_un addr = { .sun_family = AF_UNIX }; 134 struct sockaddr_un addr = { .sun_family = AF_UNIX };
128 socklen_t addrlen; 135 socklen_t addrlen;
@@ -170,14 +177,8 @@ _efl_net_dialer_unix_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Unix_Data *pd EIN
170 177
171 efl_net_dialer_address_dial_set(o, address); 178 efl_net_dialer_address_dial_set(o, address);
172 179
173 if (pd->connect.timeout) 180 if (pd->connect.timeout) eina_future_cancel(pd->connect.timeout);
174 efl_future_cancel(pd->connect.timeout); 181 if (pd->timeout_dial > 0.0) _timeout_schedule(o, pd);
175 if (pd->timeout_dial > 0.0)
176 {
177 efl_future_use(&pd->connect.timeout, efl_loop_timeout(efl_loop_get(o), pd->timeout_dial, o));
178 efl_future_then(pd->connect.timeout, _efl_net_dialer_unix_connect_timeout, NULL, NULL, o);
179 efl_future_link(o, pd->connect.timeout);
180 }
181 182
182 return 0; 183 return 0;
183} 184}
@@ -195,17 +196,12 @@ _efl_net_dialer_unix_efl_net_dialer_address_dial_get(Eo *o EINA_UNUSED, Efl_Net_
195} 196}
196 197
197EOLIAN static void 198EOLIAN static void
198_efl_net_dialer_unix_efl_net_dialer_timeout_dial_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Unix_Data *pd, double seconds) 199_efl_net_dialer_unix_efl_net_dialer_timeout_dial_set(Eo *o, Efl_Net_Dialer_Unix_Data *pd, double seconds)
199{ 200{
200 pd->timeout_dial = seconds; 201 pd->timeout_dial = seconds;
201 if (pd->connect.timeout)
202 efl_future_cancel(pd->connect.timeout);
203 202
204 if ((pd->timeout_dial > 0.0) && (pd->connect.thread)) 203 if (pd->connect.timeout) eina_future_cancel(pd->connect.timeout);
205 { 204 if ((pd->timeout_dial > 0.0) && (pd->connect.thread)) _timeout_schedule(o, pd);
206 efl_future_use(&pd->connect.timeout, efl_loop_timeout(efl_loop_get(o), pd->timeout_dial, o));
207 efl_future_then(pd->connect.timeout, _efl_net_dialer_unix_connect_timeout, NULL, NULL, o);
208 }
209} 205}
210 206
211EOLIAN static double 207EOLIAN static double
@@ -217,8 +213,7 @@ _efl_net_dialer_unix_efl_net_dialer_timeout_dial_get(Eo *o EINA_UNUSED, Efl_Net_
217EOLIAN static void 213EOLIAN static void
218_efl_net_dialer_unix_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Unix_Data *pd, Eina_Bool connected) 214_efl_net_dialer_unix_efl_net_dialer_connected_set(Eo *o, Efl_Net_Dialer_Unix_Data *pd, Eina_Bool connected)
219{ 215{
220 if (pd->connect.timeout) 216 if (pd->connect.timeout) eina_future_cancel(pd->connect.timeout);
221 efl_future_cancel(pd->connect.timeout);
222 if (pd->connected == connected) return; 217 if (pd->connected == connected) return;
223 pd->connected = connected; 218 pd->connected = connected;
224 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL); 219 if (connected) efl_event_callback_call(o, EFL_NET_DIALER_EVENT_CONNECTED, NULL);
diff --git a/src/lib/ecore_con/efl_net_dialer_websocket.c b/src/lib/ecore_con/efl_net_dialer_websocket.c
index b0a9dc4fe3..596f5b4266 100644
--- a/src/lib/ecore_con/efl_net_dialer_websocket.c
+++ b/src/lib/ecore_con/efl_net_dialer_websocket.c
@@ -159,8 +159,8 @@ typedef struct _Efl_Net_Dialer_Websocket_Pending_Read {
159 159
160typedef struct _Efl_Net_Dialer_Websocket_Data { 160typedef struct _Efl_Net_Dialer_Websocket_Data {
161 Eo *http; 161 Eo *http;
162 Efl_Future *close_timeout; 162 Eina_Future *close_timeout;
163 Efl_Future *job; 163 Eina_Future *job;
164 Eina_Stringshare *address_dial; /* must rewrite ws->http, wss->https */ 164 Eina_Stringshare *address_dial; /* must rewrite ws->http, wss->https */
165 Eina_Stringshare *address_remote; /* must rewrite ws->http, wss->https */ 165 Eina_Stringshare *address_remote; /* must rewrite ws->http, wss->https */
166 struct { 166 struct {
@@ -544,7 +544,7 @@ _efl_net_dialer_websocket_job_dispatch_frame(Eo *o, Efl_Net_Dialer_Websocket_Dat
544 else 544 else
545 efl_event_callback_call(o, EFL_IO_CLOSER_EVENT_CLOSED, NULL); 545 efl_event_callback_call(o, EFL_IO_CLOSER_EVENT_CLOSED, NULL);
546 if (pd->close_timeout) 546 if (pd->close_timeout)
547 efl_future_cancel(pd->close_timeout); 547 eina_future_cancel(pd->close_timeout);
548 break; 548 break;
549 } 549 }
550 550
@@ -734,10 +734,9 @@ _efl_net_dialer_websocket_job_receive(Eo *o, Efl_Net_Dialer_Websocket_Data *pd)
734 efl_unref(o); 734 efl_unref(o);
735} 735}
736 736
737static void 737static Eina_Value
738_efl_net_dialer_websocket_job(void *data, const Efl_Event *ev EINA_UNUSED) 738_efl_net_dialer_websocket_job(Eo *o, const Eina_Value v)
739{ 739{
740 Eo *o = data;
741 Efl_Net_Dialer_Websocket_Data *pd = efl_data_scope_get(o, MY_CLASS); 740 Efl_Net_Dialer_Websocket_Data *pd = efl_data_scope_get(o, MY_CLASS);
742 741
743 efl_ref(o); 742 efl_ref(o);
@@ -752,6 +751,7 @@ _efl_net_dialer_websocket_job(void *data, const Efl_Event *ev EINA_UNUSED)
752 _efl_net_dialer_websocket_job_schedule(o, pd); 751 _efl_net_dialer_websocket_job_schedule(o, pd);
753 752
754 efl_unref(o); 753 efl_unref(o);
754 return v;
755} 755}
756 756
757static void 757static void
@@ -763,9 +763,10 @@ _efl_net_dialer_websocket_job_schedule(Eo *o, Efl_Net_Dialer_Websocket_Data *pd)
763 763
764 loop = efl_loop_get(o); 764 loop = efl_loop_get(o);
765 if (!loop) return; 765 if (!loop) return;
766 efl_future_use(&pd->job, efl_loop_job(loop, o)); 766
767 efl_future_then(pd->job, _efl_net_dialer_websocket_job, NULL, NULL, o); 767 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_job(loop),
768 efl_future_link(o, pd->job); 768 .success = _efl_net_dialer_websocket_job,
769 .storage = &pd->job);
769} 770}
770 771
771static void 772static void
@@ -1479,13 +1480,12 @@ _efl_net_dialer_websocket_binary_send(Eo *o, Efl_Net_Dialer_Websocket_Data *pd,
1479 blob.mem, blob.len); 1480 blob.mem, blob.len);
1480} 1481}
1481 1482
1482static void 1483static Eina_Value
1483_efl_net_dialer_websocket_close_request_timeout(void *data, const Efl_Event *ev EINA_UNUSED) 1484_efl_net_dialer_websocket_close_request_timeout(Eo *o, const Eina_Value v)
1484{ 1485{
1485 Eo *o = data;
1486
1487 DBG("server did not close the TCP socket, timeout"); 1486 DBG("server did not close the TCP socket, timeout");
1488 efl_event_callback_call(o, EFL_IO_CLOSER_EVENT_CLOSED, NULL); 1487 efl_event_callback_call(o, EFL_IO_CLOSER_EVENT_CLOSED, NULL);
1488 return v;
1489} 1489}
1490 1490
1491EOLIAN static void 1491EOLIAN static void
@@ -1497,11 +1497,11 @@ _efl_net_dialer_websocket_close_request(Eo *o, Efl_Net_Dialer_Websocket_Data *pd
1497 EINA_SAFETY_ON_TRUE_RETURN(pd->close_requested); 1497 EINA_SAFETY_ON_TRUE_RETURN(pd->close_requested);
1498 1498
1499 if (pd->close_timeout) 1499 if (pd->close_timeout)
1500 efl_future_cancel(pd->close_timeout); 1500 eina_future_cancel(pd->close_timeout);
1501 1501
1502 efl_future_use(&pd->close_timeout, efl_loop_timeout(efl_loop_get(o), 2.0, o)); 1502 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_timeout(efl_loop_get(o), 2.0),
1503 efl_future_then(pd->close_timeout, _efl_net_dialer_websocket_close_request_timeout, NULL, NULL, o); 1503 .success = _efl_net_dialer_websocket_close_request_timeout,
1504 efl_future_link(o, pd->close_timeout); 1504 .storage = &pd->close_timeout);
1505 1505
1506 efl_io_writer_can_write_set(o, EINA_FALSE); 1506 efl_io_writer_can_write_set(o, EINA_FALSE);
1507 1507
diff --git a/src/lib/ecore_con/efl_net_server_windows.c b/src/lib/ecore_con/efl_net_server_windows.c
index 832782ca83..d588f773e8 100644
--- a/src/lib/ecore_con/efl_net_server_windows.c
+++ b/src/lib/ecore_con/efl_net_server_windows.c
@@ -34,7 +34,7 @@ typedef struct _Efl_Net_Server_Windows_Data
34 Eina_List *pending_clients; 34 Eina_List *pending_clients;
35 35
36 Eina_Stringshare *address; /* includes prefix: \\.\pipe\, returned without it */ 36 Eina_Stringshare *address; /* includes prefix: \\.\pipe\, returned without it */
37 Efl_Future *pending_announcer_job; 37 Eina_Future *pending_announcer_job;
38 unsigned int clients_count; 38 unsigned int clients_count;
39 unsigned int clients_limit; 39 unsigned int clients_limit;
40 Eina_Bool clients_reject_excess; 40 Eina_Bool clients_reject_excess;
@@ -316,22 +316,20 @@ _efl_net_server_windows_efl_net_server_address_get(Eo *o EINA_UNUSED, Efl_Net_Se
316 return pd->address + strlen(PIPE_NS); 316 return pd->address + strlen(PIPE_NS);
317} 317}
318 318
319static void 319static Eina_Value
320_efl_net_server_windows_pending_announce_job(void *data, const Efl_Event *ev EINA_UNUSED) 320_efl_net_server_windows_pending_announce_job(Eo *o, const Eina_Value v)
321{ 321{
322 Eo *o = data;
323 Efl_Net_Server_Windows_Data *pd = efl_data_scope_get(o, MY_CLASS); 322 Efl_Net_Server_Windows_Data *pd = efl_data_scope_get(o, MY_CLASS);
324 Eo *client; 323 Eo *client;
325 324
326 pd->pending_announcer_job = NULL; 325 if (!pd->pending_clients) return v;
327 326 if ((pd->clients_limit > 0) && (pd->clients_limit <= pd->clients_count)) return v;
328 if (!pd->pending_clients) return;
329 if ((pd->clients_limit > 0) && (pd->clients_limit <= pd->clients_count)) return;
330 327
331 client = pd->pending_clients->data; 328 client = pd->pending_clients->data;
332 pd->pending_clients = eina_list_remove_list(pd->pending_clients, pd->pending_clients); 329 pd->pending_clients = eina_list_remove_list(pd->pending_clients, pd->pending_clients);
333 330
334 efl_net_server_client_announce(o, client); 331 efl_net_server_client_announce(o, client);
332 return v;
335} 333}
336 334
337static void 335static void
@@ -345,9 +343,9 @@ _efl_net_server_windows_pending_announce_job_schedule(Eo *o, Efl_Net_Server_Wind
345 343
346 loop = efl_loop_get(o); 344 loop = efl_loop_get(o);
347 if (!loop) return; 345 if (!loop) return;
348 efl_future_use(&pd->pending_announcer_job, efl_loop_job(loop, o)); 346 efl_future_Eina_FutureXXX_then(o, efl_loop_Eina_FutureXXX_job(loop),
349 efl_future_then(pd->pending_announcer_job, _efl_net_server_windows_pending_announce_job, NULL, NULL, o); 347 .success = _efl_net_server_windows_pending_announce_job,
350 efl_future_link(o, pd->pending_announcer_job); 348 .storage = &pd->pending_announcer_job);
351} 349}
352 350
353EOLIAN static void 351EOLIAN static void