From de46a75158dc08e01adf39d363670c51ca740333 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 2 Feb 2007 12:29:21 +0000 Subject: [PATCH] Keep HAVE_POLL functionality inside its #ifdefs --- libraries/libldap/os-ip.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index e6a140a9d0..bd4796bc06 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -221,14 +221,8 @@ ldap_int_poll( ber_socket_t s, struct timeval *tvp ) { - int timeout = INFTIM; - struct timeval tv = { 0 }; int rc; - if ( tvp != NULL ) { - tv = *tvp; - timeout = TV2MILLISEC( tvp ); - } osip_debug(ld, "ldap_int_poll: fd: %d tm: %ld\n", s, tvp ? tvp->tv_sec : -1L, 0); @@ -236,10 +230,14 @@ ldap_int_poll( #ifdef HAVE_POLL { struct pollfd fd; + int timeout = INFTIM; fd.fd = s; fd.events = POLL_WRITE; + if ( tvp != NULL ) { + timeout = TV2MILLISEC( tvp ); + } do { fd.revents = 0; rc = poll( &fd, 1, timeout ); @@ -272,6 +270,7 @@ ldap_int_poll( #ifdef HAVE_WINSOCK fd_set efds; #endif + struct timeval tv = { 0 }; #if defined( FD_SETSIZE ) && !defined( HAVE_WINSOCK ) if ( s >= FD_SETSIZE ) { @@ -282,6 +281,10 @@ ldap_int_poll( } #endif + if ( tvp != NULL ) { + tv = *tvp; + } + do { FD_ZERO(&wfds); FD_SET(s, &wfds ); @@ -305,7 +308,7 @@ ldap_int_poll( return rc; } - if ( timeout == 0 && rc == 0 ) { + if ( rc == 0 && tvp && tvp->tv_sec == 0 && tvp->tv_usec == 0 ) { return -2; } -- 2.39.5