mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
Fix error detection for NT
This commit is contained in:
parent
dddf399090
commit
d706765e56
@ -46,7 +46,7 @@ int ldap_int_tblsize = 0;
|
|||||||
|
|
||||||
#define osip_debug(ld,fmt,arg1,arg2,arg3) \
|
#define osip_debug(ld,fmt,arg1,arg2,arg3) \
|
||||||
do { \
|
do { \
|
||||||
ldap_log_printf(ld, LDAP_DEBUG_TRACE, fmt, arg1, arg2, arg3); \
|
ldap_log_printf(NULL, LDAP_DEBUG_TRACE, fmt, arg1, arg2, arg3); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -132,10 +132,10 @@ ldap_pvt_prepare_socket(LDAP *ld, int fd)
|
|||||||
#undef TRACE
|
#undef TRACE
|
||||||
#define TRACE do { \
|
#define TRACE do { \
|
||||||
osip_debug(ld, \
|
osip_debug(ld, \
|
||||||
"ldap_is_socket_ready: errror on socket %d: errno: %d (%s)\n", \
|
"ldap_is_socket_ready: error on socket %d: errno: %d (%s)\n", \
|
||||||
s, \
|
s, \
|
||||||
errno, \
|
errno, \
|
||||||
strerror(errno) ); \
|
sock_errstr(errno) ); \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -187,6 +187,9 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_in *sin, int async)
|
|||||||
{
|
{
|
||||||
struct timeval tv, *opt_tv=NULL;
|
struct timeval tv, *opt_tv=NULL;
|
||||||
fd_set wfds, *z=NULL;
|
fd_set wfds, *z=NULL;
|
||||||
|
#ifdef HAVE_WINSOCK
|
||||||
|
fd_set efds;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( (opt_tv = ld->ld_options.ldo_tm_net) != NULL ) {
|
if ( (opt_tv = ld->ld_options.ldo_tm_net) != NULL ) {
|
||||||
tv.tv_usec = opt_tv->tv_usec;
|
tv.tv_usec = opt_tv->tv_usec;
|
||||||
@ -221,9 +224,30 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_in *sin, int async)
|
|||||||
FD_ZERO(&wfds);
|
FD_ZERO(&wfds);
|
||||||
FD_SET(s, &wfds );
|
FD_SET(s, &wfds );
|
||||||
|
|
||||||
if ( select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL) == -1)
|
#ifdef HAVE_WINSOCK
|
||||||
|
FD_ZERO(&efds);
|
||||||
|
FD_SET(s, &efds );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( select(ldap_int_tblsize, z, &wfds,
|
||||||
|
#ifdef HAVE_WINSOCK
|
||||||
|
&efds,
|
||||||
|
#else
|
||||||
|
z,
|
||||||
|
#endif
|
||||||
|
opt_tv ? &tv : NULL) == -1)
|
||||||
return ( -1 );
|
return ( -1 );
|
||||||
|
|
||||||
|
#ifdef HAVE_WINSOCK
|
||||||
|
/* This means the connection failed */
|
||||||
|
if (FD_ISSET(s, &efds))
|
||||||
|
{
|
||||||
|
ldap_pvt_set_errno(WSAECONNREFUSED);
|
||||||
|
osip_debug(ld, "ldap_pvt_connect: error on socket %d: "
|
||||||
|
"errno: %d (%s)\n", s, errno, sock_errstr(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if ( FD_ISSET(s, &wfds) ) {
|
if ( FD_ISSET(s, &wfds) ) {
|
||||||
if ( ldap_pvt_is_socket_ready(ld, s) == -1 )
|
if ( ldap_pvt_is_socket_ready(ld, s) == -1 )
|
||||||
return ( -1 );
|
return ( -1 );
|
||||||
|
Loading…
Reference in New Issue
Block a user