From 58a358e7b237502afd7451b2492d34cc66e1cc62 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 26 Apr 2005 21:48:43 +0000 Subject: [PATCH] more cleanup in handling timeouts in ldap_result() --- servers/slapd/back-meta/bind.c | 25 +++++++++++++++++++++++-- servers/slapd/back-meta/search.c | 13 ++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index f0e0c50024..1c088369ae 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -181,7 +181,8 @@ meta_back_single_bind( struct berval mdn = BER_BVNULL; dncookie dc; metasingleconn_t *msc = &mc->mc_conns[ candidate ]; - int msgid; + int msgid, + rebinding = 0; /* * Rewrite the bind dn if needed @@ -230,12 +231,27 @@ retry:; goto retry; } rs->sr_err = LDAP_BUSY; - break; + if ( rebinding ) { + ldap_abandon_ext( msc->msc_ld, msgid, NULL, NULL ); + break; + } + + /* FIXME: some times the request times out + * while the other party is not willing to + * send a response any more. Give it a second + * chance with a freshly bound connection */ + rebinding = 1; + nretries = mt->mt_nretries; + /* fallthru */ case -1: ldap_get_option( msc->msc_ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err ); + if ( rebinding ) { + ldap_abandon_ext( msc->msc_ld, msgid, NULL, NULL ); + } + Debug( LDAP_DEBUG_ANY, "### %s meta_back_single_bind: err=%d nretries=%d\n", op->o_log_prefix, rs->sr_err, nretries ); @@ -365,6 +381,7 @@ retry:; rc = LDAP_BUSY; if ( rebinding ) { + ldap_abandon_ext( msc->msc_ld, msgid, NULL, NULL ); break; } @@ -380,6 +397,10 @@ retry:; ldap_get_option( msc->msc_ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err ); + if ( rebinding ) { + ldap_abandon_ext( msc->msc_ld, msgid, NULL, NULL ); + } + Debug( LDAP_DEBUG_ANY, "### %s meta_back_single_dobind: err=%d nretries=%d\n", op->o_log_prefix, rs->sr_err, nretries ); diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 888cb7af65..e88b7e9162 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -388,6 +388,7 @@ really_bad:; gotit = 1; +#if 0 /* * If scope is BASE, we need to jump out * as soon as one entry is found; if @@ -395,6 +396,10 @@ really_bad:; * this should correspond to the sole * entry that has the base DN */ + /* FIXME: this defeats the purpose of + * doing a search with scope == base and + * sizelimit = 1 to determine if a + * candidate is actually unique */ if ( op->ors_scope == LDAP_SCOPE_BASE && rs->sr_nentries > 0 ) { @@ -403,6 +408,7 @@ really_bad:; sres = LDAP_SUCCESS; break; } +#endif } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) { char **references = NULL; @@ -843,12 +849,13 @@ meta_send_entry( } if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR - || attr->a_vals == NULL ) { + || attr->a_vals == NULL ) + { attr->a_vals = (struct berval *)&slap_dummy_bv; } else if ( attr->a_desc == slap_schema.si_ad_objectClass - || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) { - + || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) + { for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); ++last ); for ( bv = attr->a_vals; !BER_BVISNULL( bv ); bv++ ) { -- 2.39.5