From 9b5ea6a2057af584b44fa769ae36e2b75495608f Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 7 Jan 2007 22:05:33 +0000 Subject: [PATCH] honor network timeout even when doing full async --- libraries/libldap/ldap-int.h | 1 + libraries/libldap/open.c | 2 ++ libraries/libldap/request.c | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index e37a7b81c3..31f386b99c 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -243,6 +243,7 @@ typedef struct ldap_conn { void *lconn_sasl_sockctx; /* for security layer */ #endif int lconn_refcnt; + time_t lconn_created; /* time */ time_t lconn_lastused; /* time */ int lconn_rebind_inprogress; /* set if rebind in progress */ char ***lconn_rebind_queue; /* used if rebind in progress */ diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index f10eb7c104..4d28619110 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -345,6 +345,8 @@ ldap_int_open_connection( break; } + conn->lconn_created = time( NULL ); + #ifdef LDAP_DEBUG ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug, INT_MAX, (void *)"ldap_" ); diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index bf81bd6f44..8e42db67a0 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -223,10 +223,18 @@ ldap_send_server_request( lc->lconn_status = LDAP_CONNST_CONNECTED; break; - case -2: - /* caller will have to call again */ - ld->ld_errno = LDAP_X_CONNECTING; - /* fallthru */ + case -2: { + /* async only occurs if a network timeout is set */ + struct timeval *tvp = ld->ld_options.ldo_tm_net; + assert( tvp != NULL ); + + /* honor network timeout */ + if ( time( NULL ) - lc->lconn_created <= tvp->tv_sec ) + { + /* caller will have to call again */ + ld->ld_errno = LDAP_X_CONNECTING; + } + } /* fallthru */ default: /* error */ -- 2.39.5