From: Pierangelo Masarati Date: Sun, 3 Sep 2006 11:02:15 +0000 (+0000) Subject: back-ldap should only touch the connection timestamp when activity actually occurred... X-Git-Tag: OPENLDAP_REL_ENG_2_3_MP~219 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=00c249854355def8de16bcd27a619a48978539f8;p=openldap back-ldap should only touch the connection timestamp when activity actually occurred (i.e. ldap_result() returned a positive value), otherwise if "the network cable is removed after the connection is established" ldap_result() keeps returning 0 forever... --- diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 9d36a4a768..2d3527e239 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -505,6 +505,7 @@ ldap_back_prepare_conn( ldapconn_t **lcp, Operation *op, SlapReply *rs, ldap_bac #ifdef HAVE_TLS int is_tls = op->o_conn->c_is_tls; #endif /* HAVE_TLS */ + time_t lc_time = (time_t)(-1); assert( lcp != NULL ); @@ -554,6 +555,10 @@ ldap_back_prepare_conn( ldapconn_t **lcp, Operation *op, SlapReply *rs, ldap_bac if ( rs->sr_err != LDAP_SUCCESS ) { ldap_unbind_ext( ld, NULL, NULL ); goto error_return; + + } else if ( li->li_idle_timeout ) { + /* only touch when activity actually took place... */ + lc_time = op->o_time; } #endif /* HAVE_TLS */ @@ -570,6 +575,9 @@ ldap_back_prepare_conn( ldapconn_t **lcp, Operation *op, SlapReply *rs, ldap_bac } else { LDAP_BACK_CONN_ISTLS_CLEAR( *lcp ); } + if ( lc_time != (time_t)(-1) ) { + (*lcp)->lc_time = lc_time; + } #endif /* HAVE_TLS */ error_return:; @@ -804,9 +812,6 @@ retry_lock: #ifdef HAVE_TLS done:; #endif /* HAVE_TLS */ - if ( li->li_idle_timeout && lc ) { - lc->lc_time = op->o_time; - } return lc; } @@ -1302,6 +1307,11 @@ retry:; * structure (this includes * LDAP_COMPARE_{TRUE|FALSE}) */ default: + /* only touch when activity actually took place... */ + if ( li->li_idle_timeout && lc ) { + lc->lc_time = op->o_time; + } + rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, &match, &text, &refs, &ctrls, 1 ); rs->sr_text = text; diff --git a/servers/slapd/back-ldap/extended.c b/servers/slapd/back-ldap/extended.c index 9af2738a8b..0a4620f8b2 100644 --- a/servers/slapd/back-ldap/extended.c +++ b/servers/slapd/back-ldap/extended.c @@ -142,6 +142,11 @@ retry: rs->sr_err = rc; } else { + /* only touch when activity actually took place... */ + if ( li->li_idle_timeout && lc ) { + lc->lc_time = op->o_time; + } + /* sigh. parse twice, because parse_passwd * doesn't give us the err / match / msg info. */ @@ -252,6 +257,11 @@ retry: rs->sr_err = rc; } else { + /* only touch when activity actually took place... */ + if ( li->li_idle_timeout && lc ) { + lc->lc_time = op->o_time; + } + /* sigh. parse twice, because parse_passwd * doesn't give us the err / match / msg info. */ diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index a122b85dfb..b5647e5dc9 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -287,6 +287,11 @@ retry: continue; } else { + /* only touch when activity actually took place... */ + if ( li->li_idle_timeout && lc ) { + lc->lc_time = op->o_time; + } + /* don't retry any more */ dont_retry = 1; }