barbieri pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7a842e06128a3c60fd0c0a20006d5e7d6898e37d
commit 7a842e06128a3c60fd0c0a20006d5e7d6898e37d Author: Gustavo Sverzut Barbieri <[email protected]> Date: Wed Oct 26 17:51:58 2016 -0200 efl_net_dialer_tcp: make code bit more robust. Also avoids the double-set of remote address, since socket.tcp will alredy do that for us when we efl_loop_fd_set(). --- src/lib/ecore_con/efl_net_dialer_tcp.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lib/ecore_con/efl_net_dialer_tcp.c b/src/lib/ecore_con/efl_net_dialer_tcp.c index e6224c9..0b04978 100644 --- a/src/lib/ecore_con/efl_net_dialer_tcp.c +++ b/src/lib/ecore_con/efl_net_dialer_tcp.c @@ -96,27 +96,33 @@ _efl_net_dialer_tcp_connected(void *data, const struct sockaddr *addr, socklen_t { Eo *o = data; Efl_Net_Dialer_Tcp_Data *pd = efl_data_scope_get(o, MY_CLASS); - char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")]; pd->connect.thread = NULL; efl_ref(o); /* we're emitting callbacks then continuing the workflow */ - if (err) + if (err) goto error; + + efl_net_socket_fd_family_set(o, addr->sa_family); + efl_loop_fd_set(o, sockfd); + if (efl_net_socket_address_remote_get(o)) { - efl_io_reader_eos_set(o, EINA_TRUE); - efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err); + efl_event_callback_call(o, EFL_NET_DIALER_EVENT_RESOLVED, NULL); + efl_net_dialer_connected_set(o, EINA_TRUE); } else { - efl_net_socket_fd_family_set(o, addr->sa_family); - efl_loop_fd_set(o, sockfd); - if (efl_net_ip_port_fmt(buf, sizeof(buf), addr)) - { - efl_net_socket_address_remote_set(o, buf); - efl_event_callback_call(o, EFL_NET_DIALER_EVENT_RESOLVED, NULL); - } - efl_net_dialer_connected_set(o, EINA_TRUE); + err = EFL_NET_DIALER_ERROR_COULDNT_CONNECT; + efl_loop_fd_set(o, INVALID_SOCKET); + closesocket(sockfd); + goto error; + } + + error: + if (err) + { + efl_io_reader_eos_set(o, EINA_TRUE); + efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err); } efl_unref(o); --
