aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-09 12:08:29 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-09 13:47:04 -0200
commit5939f0d9c204e7a8face4a68c953440344fc7941 (patch)
tree6b70a7f27e5fcafce0d30645bb1d84652e54472d
parentefl_net: optimize serving of IP addresses. (diff)
downloadefl-5939f0d9c204e7a8face4a68c953440344fc7941.tar.gz
efl_net_dialer: emit 'resolved' even if connection failed.
If we resolved the address but couldn't connect, use efl_net_socket_address_remote_set() and emit EFL_NET_DIALER_EVENT_RESOLVED.
-rw-r--r--src/lib/ecore_con/ecore_con.c9
-rw-r--r--src/lib/ecore_con/efl_net_dialer_tcp.c9
-rw-r--r--src/lib/ecore_con/efl_net_dialer_udp.c12
3 files changed, 28 insertions, 2 deletions
diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index 84f639d85f..e9dfd7621a 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -3867,7 +3867,14 @@ _efl_net_ip_resolve_and_connect(const char *host, const char *port, int type, in
}
}
if (ret != 0)
- ret = EFL_NET_DIALER_ERROR_COULDNT_CONNECT;
+ {
+ if (results)
+ {
+ memcpy(addr, results->ai_addr, results->ai_addrlen);
+ *p_addrlen = results->ai_addrlen;
+ }
+ ret = EFL_NET_DIALER_ERROR_COULDNT_CONNECT;
+ }
EINA_THREAD_CLEANUP_POP(EINA_TRUE);
}
return ret;
diff --git a/src/lib/ecore_con/efl_net_dialer_tcp.c b/src/lib/ecore_con/efl_net_dialer_tcp.c
index e04707412d..70aa4219cd 100644
--- a/src/lib/ecore_con/efl_net_dialer_tcp.c
+++ b/src/lib/ecore_con/efl_net_dialer_tcp.c
@@ -120,6 +120,15 @@ _efl_net_dialer_tcp_connected(void *data, const struct sockaddr *addr, socklen_t
error:
if (err)
{
+ if (addr && addr->sa_family)
+ {
+ char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = "";
+ 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_io_reader_eos_set(o, EINA_TRUE);
efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err);
}
diff --git a/src/lib/ecore_con/efl_net_dialer_udp.c b/src/lib/ecore_con/efl_net_dialer_udp.c
index 327a629fe8..9b7e687758 100644
--- a/src/lib/ecore_con/efl_net_dialer_udp.c
+++ b/src/lib/ecore_con/efl_net_dialer_udp.c
@@ -198,14 +198,24 @@ _efl_net_dialer_udp_resolved(void *data, const char *host EINA_UNUSED, const cha
err = _efl_net_dialer_udp_resolved_bind(o, pd, addr);
if (err == 0) break;
}
- freeaddrinfo(result);
end:
if (err)
{
+ if (result)
+ {
+ char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = "";
+ if (efl_net_ip_port_fmt(buf, sizeof(buf), result->ai_addr))
+ {
+ efl_net_socket_address_remote_set(o, buf);
+ efl_event_callback_call(o, EFL_NET_DIALER_EVENT_RESOLVED, NULL);
+ }
+ }
+
efl_io_reader_eos_set(o, EINA_TRUE);
efl_event_callback_call(o, EFL_NET_DIALER_EVENT_ERROR, &err);
}
+ freeaddrinfo(result);
efl_unref(o);
}