[gq-commit] gq/src util.c,1.77,1.78
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2003-10-21 08:20:09
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv10199 Modified Files: util.c Log Message: * Avoid some redundant, time-consuming connection attempts when an LDAP server is reportedly down. Cuts down dead-time in certain situations Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** util.c 20 Oct 2003 08:33:38 -0000 1.77 --- util.c 21 Oct 2003 04:57:34 -0000 1.78 *************** *** 72,75 **** --- 72,77 ---- #define TRY_VERSION3 1 + LDAP *open_connection_ex(struct ldapserver *server, int *ldap_errno); + #ifdef HAVE_SASL static int util_ldap_sasl_interact(LDAP *ld, unsigned flags, void *defaults, void *in) *************** *** 358,361 **** --- 360,364 ---- LDAPURLDesc *desc = NULL; struct ldapserver *newserver = NULL, *s; + int ld_err; assert(parent); *************** *** 382,386 **** newserver->quiet = 1; ! if (open_connection(newserver)) { close_connection(newserver, FALSE); --- 385,389 ---- newserver->quiet = 1; ! if (open_connection_ex(newserver, &ld_err)) { close_connection(newserver, FALSE); *************** *** 389,392 **** --- 392,398 ---- goto done; } + if (ld_err == LDAP_SERVER_DOWN) { + goto done; + } /* check: do we have this server around already??? */ *************** *** 406,414 **** newserver->quiet = 1; ! if (open_connection(newserver)) { close_connection(newserver, FALSE); statusbar_msg(_("Initialized temporary server-definition '%1$s' from existing server '%2$s'"), new_uri->str, s->name); goto done; } } --- 412,423 ---- newserver->quiet = 1; ! if (open_connection_ex(newserver, &ld_err)) { close_connection(newserver, FALSE); statusbar_msg(_("Initialized temporary server-definition '%1$s' from existing server '%2$s'"), new_uri->str, s->name); goto done; } + if (ld_err == LDAP_SERVER_DOWN) { + goto done; + } } *************** *** 426,434 **** newserver->bindtype = BINDTYPE_SIMPLE; ! if (open_connection(newserver)) { close_connection(newserver, FALSE); statusbar_msg(_("Initialized temporary server-definition '%1$s' from existing server '%2$s'"), new_uri->str, parent->name); goto done; } /* nothing usable found - retry */ } --- 435,446 ---- newserver->bindtype = BINDTYPE_SIMPLE; ! if (open_connection_ex(newserver, &ld_err)) { close_connection(newserver, FALSE); statusbar_msg(_("Initialized temporary server-definition '%1$s' from existing server '%2$s'"), new_uri->str, parent->name); goto done; } + if (ld_err == LDAP_SERVER_DOWN) { + goto done; + } /* nothing usable found - retry */ } *************** *** 449,453 **** * open connection to LDAP server, and store connection for caching */ ! LDAP *open_connection(struct ldapserver *server) { LDAP *ld; --- 461,465 ---- * open connection to LDAP server, and store connection for caching */ ! LDAP *open_connection_ex(struct ldapserver *server, int *ldap_errno) { LDAP *ld; *************** *** 457,460 **** --- 469,473 ---- int newpw = 0; + if (ldap_errno) *ldap_errno = LDAP_SUCCESS; if(!server) return NULL; *************** *** 529,535 **** --- 542,554 ---- } + if (ldap_errno) *ldap_errno = rc; + return(ld); } + LDAP *open_connection(struct ldapserver *server) + { + return open_connection_ex(server, NULL); + } /* |