|
|
5ed10d |
Fix back-ldap to respect the user configured timeout
|
|
|
5ed10d |
|
|
|
5ed10d |
Upstream: ITS#8720
|
|
|
5ed10d |
Resolves: #1540336
|
|
|
5ed10d |
|
|
|
5ed10d |
diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h
|
|
|
5ed10d |
index 1e2c14a..e35f622 100644
|
|
|
5ed10d |
--- a/servers/slapd/back-ldap/back-ldap.h
|
|
|
5ed10d |
+++ b/servers/slapd/back-ldap/back-ldap.h
|
|
|
5ed10d |
@@ -89,6 +89,7 @@ typedef struct ldapconn_base_t {
|
|
|
5ed10d |
(BER_BVISEMPTY(&(op)->o_ndn) ? \
|
|
|
5ed10d |
LDAP_BACK_PCONN_ANON_SET((lc), (op)) : LDAP_BACK_PCONN_ROOTDN_SET((lc), (op)))
|
|
|
5ed10d |
|
|
|
5ed10d |
+ struct ldapinfo_t *lcb_ldapinfo;
|
|
|
5ed10d |
struct berval lcb_local_ndn;
|
|
|
5ed10d |
unsigned lcb_refcnt;
|
|
|
5ed10d |
time_t lcb_create_time;
|
|
|
5ed10d |
@@ -98,6 +99,7 @@ typedef struct ldapconn_base_t {
|
|
|
5ed10d |
typedef struct ldapconn_t {
|
|
|
5ed10d |
ldapconn_base_t lc_base;
|
|
|
5ed10d |
#define lc_conn lc_base.lcb_conn
|
|
|
5ed10d |
+#define lc_ldapinfo lc_base.lcb_ldapinfo
|
|
|
5ed10d |
#define lc_local_ndn lc_base.lcb_local_ndn
|
|
|
5ed10d |
#define lc_refcnt lc_base.lcb_refcnt
|
|
|
5ed10d |
#define lc_create_time lc_base.lcb_create_time
|
|
|
5ed10d |
diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c
|
|
|
5ed10d |
index ff759d7..7808f7a 100644
|
|
|
5ed10d |
--- a/servers/slapd/back-ldap/bind.c
|
|
|
5ed10d |
+++ b/servers/slapd/back-ldap/bind.c
|
|
|
5ed10d |
@@ -532,7 +532,7 @@ ldap_back_start_tls(
|
|
|
5ed10d |
int *is_tls,
|
|
|
5ed10d |
const char *url,
|
|
|
5ed10d |
unsigned flags,
|
|
|
5ed10d |
- int retries,
|
|
|
5ed10d |
+ int timeout,
|
|
|
5ed10d |
const char **text )
|
|
|
5ed10d |
{
|
|
|
5ed10d |
int rc = LDAP_SUCCESS;
|
|
|
5ed10d |
@@ -567,22 +567,14 @@ ldap_back_start_tls(
|
|
|
5ed10d |
LDAPMessage *res = NULL;
|
|
|
5ed10d |
struct timeval tv;
|
|
|
5ed10d |
|
|
|
5ed10d |
- LDAP_BACK_TV_SET( &tv );
|
|
|
5ed10d |
-
|
|
|
5ed10d |
-retry:;
|
|
|
5ed10d |
+ if ( timeout ) {
|
|
|
5ed10d |
+ tv.tv_sec = timeout;
|
|
|
5ed10d |
+ tv.tv_usec = 0;
|
|
|
5ed10d |
+ } else {
|
|
|
5ed10d |
+ LDAP_BACK_TV_SET( &tv );
|
|
|
5ed10d |
+ }
|
|
|
5ed10d |
rc = ldap_result( ld, msgid, LDAP_MSG_ALL, &tv, &res );
|
|
|
5ed10d |
- if ( rc < 0 ) {
|
|
|
5ed10d |
- rc = LDAP_UNAVAILABLE;
|
|
|
5ed10d |
-
|
|
|
5ed10d |
- } else if ( rc == 0 ) {
|
|
|
5ed10d |
- if ( retries != LDAP_BACK_RETRY_NEVER ) {
|
|
|
5ed10d |
- ldap_pvt_thread_yield();
|
|
|
5ed10d |
- if ( retries > 0 ) {
|
|
|
5ed10d |
- retries--;
|
|
|
5ed10d |
- }
|
|
|
5ed10d |
- LDAP_BACK_TV_SET( &tv );
|
|
|
5ed10d |
- goto retry;
|
|
|
5ed10d |
- }
|
|
|
5ed10d |
+ if ( rc <= 0 ) {
|
|
|
5ed10d |
rc = LDAP_UNAVAILABLE;
|
|
|
5ed10d |
|
|
|
5ed10d |
} else if ( rc == LDAP_RES_EXTENDED ) {
|
|
|
5ed10d |
@@ -754,7 +746,7 @@ ldap_back_prepare_conn( ldapconn_t *lc, Operation *op, SlapReply *rs, ldap_back_
|
|
|
5ed10d |
assert( li->li_uri_mutex_do_not_lock == 0 );
|
|
|
5ed10d |
li->li_uri_mutex_do_not_lock = 1;
|
|
|
5ed10d |
rs->sr_err = ldap_back_start_tls( ld, op->o_protocol, &is_tls,
|
|
|
5ed10d |
- li->li_uri, flags, li->li_nretries, &rs->sr_text );
|
|
|
5ed10d |
+ li->li_uri, flags, li->li_timeout[ SLAP_OP_EXTENDED ], &rs->sr_text );
|
|
|
5ed10d |
li->li_uri_mutex_do_not_lock = 0;
|
|
|
5ed10d |
ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex );
|
|
|
5ed10d |
if ( rs->sr_err != LDAP_SUCCESS ) {
|
|
|
5ed10d |
@@ -980,6 +972,7 @@ retry_lock:
|
|
|
5ed10d |
lc = (ldapconn_t *)ch_calloc( 1, sizeof( ldapconn_t ) );
|
|
|
5ed10d |
lc->lc_flags = li->li_flags;
|
|
|
5ed10d |
lc->lc_lcflags = lc_curr.lc_lcflags;
|
|
|
5ed10d |
+ lc->lc_ldapinfo = li;
|
|
|
5ed10d |
if ( ldap_back_prepare_conn( lc, op, rs, sendok ) != LDAP_SUCCESS ) {
|
|
|
5ed10d |
ch_free( lc );
|
|
|
5ed10d |
return NULL;
|
|
|
5ed10d |
@@ -1649,7 +1642,7 @@ ldap_back_default_rebind( LDAP *ld, LDAP_CONST char *url, ber_tag_t request,
|
|
|
5ed10d |
const char *text = NULL;
|
|
|
5ed10d |
|
|
|
5ed10d |
rc = ldap_back_start_tls( ld, 0, &is_tls, url, lc->lc_flags,
|
|
|
5ed10d |
- LDAP_BACK_RETRY_DEFAULT, &text );
|
|
|
5ed10d |
+ lc->lc_ldapinfo->li_timeout[ SLAP_OP_EXTENDED ], &text );
|
|
|
5ed10d |
if ( rc != LDAP_SUCCESS ) {
|
|
|
5ed10d |
return rc;
|
|
|
5ed10d |
}
|