Merge pull request #1950 from hardening/kill_select

kill the last remaining select() in libfreerdp
This commit is contained in:
Bernhard Miklautz 2014-07-11 16:41:31 +02:00
commit c99d4648ff

View File

@ -509,8 +509,12 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout)
}
else
{
#ifdef HAVE_POLL_H
struct pollfd pollfds;
#else
fd_set cfds;
struct timeval tv;
#endif
tcp->socketBio = BIO_new(BIO_s_connect());
@ -534,14 +538,24 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout)
if (status <= 0)
{
#ifdef HAVE_POLL_H
pollfds.fd = tcp->sockfd;
pollfds.events = POLLOUT;
pollfds.revents = 0;
do
{
status = poll(&pollfds, 1, timeout * 1000);
}
while ((status < 0) && (errno == EINTR));
#else
FD_ZERO(&cfds);
FD_SET(tcp->sockfd, &cfds);
tv.tv_sec = timeout;
tv.tv_usec = 0;
status = select(tcp->sockfd + 1, NULL, &cfds, NULL, &tv);
status = _select(tcp->sockfd + 1, NULL, &cfds, NULL, &tv);
#endif
if (status == 0)
{
return FALSE; /* timeout */