nss-pam-ldapd commit: r1211 - in nss-pam-ldapd-0.7: . nslcd
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1211 - in nss-pam-ldapd-0.7: . nslcd
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1211 - in nss-pam-ldapd-0.7: . nslcd
- Date: Fri, 24 Sep 2010 09:16:10 +0200 (CEST)
Author: arthur
Date: Fri Sep 24 09:16:08 2010
New Revision: 1211
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1211
Log:
handle errors from ldap_result() better and disconnect (and reconnect) in more
cases (r1207 and r1208 from trunk)
Modified:
nss-pam-ldapd-0.7/ (props changed)
nss-pam-ldapd-0.7/nslcd/myldap.c
Modified: nss-pam-ldapd-0.7/nslcd/myldap.c
==============================================================================
--- nss-pam-ldapd-0.7/nslcd/myldap.c Fri Sep 24 09:11:38 2010 (r1210)
+++ nss-pam-ldapd-0.7/nslcd/myldap.c Fri Sep 24 09:16:08 2010 (r1211)
@@ -1060,36 +1060,6 @@
/* handle result */
switch (rc)
{
- case -1:
- /* we have an error condition, try to get error code */
- if
(ldap_get_option(search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
- rc=LDAP_UNAVAILABLE;
- log_log(LOG_ERR,"ldap_result() failed: %s",ldap_err2string(rc));
- /* close connection on connection problems */
- if ((rc==LDAP_UNAVAILABLE)||(rc==LDAP_SERVER_DOWN)||(rc==LDAP_SUCCESS))
- {
- /* close the connection and retry */
- do_close(search->session);
- if (search->may_retry_search)
- {
- log_log(LOG_DEBUG,"myldap_get_entry(): retry search");
- search->may_retry_search=0;
- if (do_retry_search(search)==LDAP_SUCCESS)
- return myldap_get_entry(search,rcp);
- }
- }
- /* close search */
- myldap_search_close(search);
- if (rcp!=NULL)
- *rcp=rc;
- return NULL;
- case 0:
- /* the timeout expired */
- log_log(LOG_ERR,"ldap_result() timed out");
- myldap_search_close(search);
- if (rcp!=NULL)
- *rcp=LDAP_TIMELIMIT_EXCEEDED;
- return NULL;
case LDAP_RES_SEARCH_ENTRY:
/* we have a normal search entry, update timestamp and return result */
time(&(search->session->lastactivity));
@@ -1205,11 +1175,46 @@
case LDAP_RES_SEARCH_REFERENCE:
break; /* just ignore search references */
default:
- log_log(LOG_WARNING,"ldap_result() returned unexpected result type");
+ /* we have some error condition, find out which */
+ switch (rc)
+ {
+ case -1:
+ /* try to get error code */
+ if
(ldap_get_option(search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
+ rc=LDAP_UNAVAILABLE;
+ log_log(LOG_ERR,"ldap_result() failed: %s",ldap_err2string(rc));
+ break;
+ case 0:
+ /* the timeout expired */
+ log_log(LOG_ERR,"ldap_result() timed out");
+ rc=LDAP_TIMELIMIT_EXCEEDED;
+ break;
+ default:
+ /* unknown code */
+ log_log(LOG_WARNING,"ldap_result() returned unexpected result
type");
+ rc=LDAP_PROTOCOL_ERROR;
+ }
+ /* close connection on some connection problems */
+ if
((rc==LDAP_UNAVAILABLE)||(rc==LDAP_SERVER_DOWN)||(rc==LDAP_SUCCESS)||
+ (rc==LDAP_TIMELIMIT_EXCEEDED)|(rc==LDAP_OPERATIONS_ERROR)||
+ (rc==LDAP_PROTOCOL_ERROR))
+ {
+ do_close(search->session);
+ /* retry once if no data has been received yet */
+ if (search->may_retry_search)
+ {
+ log_log(LOG_DEBUG,"myldap_get_entry(): retry search");
+ search->may_retry_search=0;
+ if (do_retry_search(search)==LDAP_SUCCESS)
+ return myldap_get_entry(search,rcp);
+ }
+ }
+ /* close search */
myldap_search_close(search);
if (rcp!=NULL)
- *rcp=LDAP_PROTOCOL_ERROR;
+ *rcp=rc;
return NULL;
+
}
}
}
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1211 - in nss-pam-ldapd-0.7: . nslcd,
Commits of the nss-pam-ldapd project