Merge pull request #1950 from hardening/kill_select
kill the last remaining select() in libfreerdp
This commit is contained in:
commit
c99d4648ff
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user