ecore_con: Fix connect() handling

If connect() returns 0, we must send the ECORE_CON_EVENT_SERVER_ADD event
because it wont be given by select(). select() will ONLY notice it if connect
returns -1 with errno set to EINPROGRESS.

This bug is reproductible with 100% chance using ecore_con_telnet_client example
from https://github.com/gfriloux/examples if you connect to 127.0.0.1 instead of
of an external network ip, under FreeBSD (and likely any BSD).

Seems very rare to trigger it under GNU/Linux as it seems that connect()
doesnt want to return 0 when having non blocking sockets (or is too slow),
but it seems i was having this bug too on production servers, without being
ever able to reproduce it.
This commit is contained in:
Guillaume Friloux 2014-10-08 11:53:15 +02:00 committed by zmike
parent ad2c51c034
commit 101c13d582
1 changed files with 5 additions and 2 deletions

View File

@ -1772,8 +1772,11 @@ _ecore_con_cb_tcp_connect(void *data,
_ecore_con_cl_handler, obj, NULL, NULL);
}
else
svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
_ecore_con_cl_handler, obj, NULL, NULL);
{
ecore_con_event_server_add(obj);
svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
_ecore_con_cl_handler, obj, NULL, NULL);
}
if (svr->type & ECORE_CON_SSL)
{