mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
Fix up restart code for EINTR
This commit is contained in:
parent
c054d8458a
commit
dc4413349e
@ -158,16 +158,14 @@ ldap_get_option(
|
||||
|
||||
case LDAP_OPT_TIMEOUT:
|
||||
/* the caller has to free outvalue ! */
|
||||
if ( ldap_int_timeval_dup( outvalue, lo->ldo_tm_api) != 0 )
|
||||
{
|
||||
if ( ldap_int_timeval_dup( outvalue, lo->ldo_tm_api) != 0 ) {
|
||||
return LDAP_OPT_ERROR;
|
||||
}
|
||||
return LDAP_OPT_SUCCESS;
|
||||
|
||||
case LDAP_OPT_NETWORK_TIMEOUT:
|
||||
/* the caller has to free outvalue ! */
|
||||
if ( ldap_int_timeval_dup( outvalue, lo->ldo_tm_net ) != 0 )
|
||||
{
|
||||
if ( ldap_int_timeval_dup( outvalue, lo->ldo_tm_net ) != 0 ) {
|
||||
return LDAP_OPT_ERROR;
|
||||
}
|
||||
return LDAP_OPT_SUCCESS;
|
||||
|
@ -201,6 +201,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
|
||||
struct sockaddr *sin, socklen_t addrlen,
|
||||
int async)
|
||||
{
|
||||
int rc;
|
||||
struct timeval tv, *opt_tv=NULL;
|
||||
fd_set wfds, *z=NULL;
|
||||
#ifdef HAVE_WINSOCK
|
||||
@ -230,8 +231,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
|
||||
if ( ldap_pvt_ndelay_on(ld, s) == -1 )
|
||||
return ( -1 );
|
||||
|
||||
if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR )
|
||||
{
|
||||
if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR ) {
|
||||
if ( ldap_pvt_ndelay_off(ld, s) == -1 )
|
||||
return ( -1 );
|
||||
return ( 0 );
|
||||
@ -257,16 +257,18 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
|
||||
FD_SET(s, &efds );
|
||||
#endif
|
||||
|
||||
if ( select(ldap_int_tblsize, z, &wfds,
|
||||
do {
|
||||
rc = select(ldap_int_tblsize, z, &wfds,
|
||||
#ifdef HAVE_WINSOCK
|
||||
&efds,
|
||||
&efds,
|
||||
#else
|
||||
z,
|
||||
z,
|
||||
#endif
|
||||
opt_tv ? &tv : NULL) == AC_SOCKET_ERROR )
|
||||
{
|
||||
return ( -1 );
|
||||
}
|
||||
opt_tv ? &tv : NULL);
|
||||
} while( rc == AC_SOCKET_ERROR && errno == EINTR &&
|
||||
LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART ));
|
||||
|
||||
if( rc == AC_SOCKET_ERROR ) return rc;
|
||||
|
||||
#ifdef HAVE_WINSOCK
|
||||
/* This means the connection failed */
|
||||
|
@ -134,6 +134,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
|
||||
static int
|
||||
ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async)
|
||||
{
|
||||
int rc;
|
||||
struct timeval tv, *opt_tv=NULL;
|
||||
fd_set wfds, *z=NULL;
|
||||
|
||||
@ -168,11 +169,12 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async)
|
||||
FD_ZERO(&wfds);
|
||||
FD_SET(s, &wfds );
|
||||
|
||||
if ( select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL)
|
||||
== AC_SOCKET_ERROR )
|
||||
{
|
||||
return ( -1 );
|
||||
}
|
||||
do {
|
||||
rc = select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL);
|
||||
} while( rc == AC_SOCKET_ERROR && errno == EINTR &&
|
||||
LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART ));
|
||||
|
||||
if( rc == AC_SOCKET_ERROR ) return rc;
|
||||
|
||||
if ( FD_ISSET(s, &wfds) ) {
|
||||
if ( ldap_pvt_is_socket_ready(ld, s) == -1 )
|
||||
|
Loading…
Reference in New Issue
Block a user