nss-pam-ldapd commit: r1291 - in nss-pam-ldapd-0.7: . nslcd
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1291 - 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: r1291 - in nss-pam-ldapd-0.7: . nslcd
- Date: Fri, 29 Oct 2010 17:03:44 +0200 (CEST)
Author: arthur
Date: Fri Oct 29 17:03:43 2010
New Revision: 1291
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1291
Log:
set a short socket timeout when shutting down the connection to the LDAP
server (part of r1276 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 Thu Oct 28 23:17:00 2010 (r1290)
+++ nss-pam-ldapd-0.7/nslcd/myldap.c Fri Oct 29 17:03:43 2010 (r1291)
@@ -547,6 +547,20 @@
{
int i;
int rc;
+ int sd=-1;
+ struct timeval tv;
+ /* set timeout options on socket to avoid hang in some cases
+ (we set a short timeout because we don't care too much about properly
+ shutting down the connection) */
+ if (ldap_get_option(session->ld,LDAP_OPT_DESC,&sd)==LDAP_SUCCESS)
+ {
+ /* ignore errors */
+ tv.tv_sec=nslcd_cfg->ldc_timelimit/2;
+ if (!tv.tv_sec) tv.tv_sec=1;
+ tv.tv_usec=0;
+ (void)setsockopt(sd,SOL_SOCKET,SO_RCVTIMEO,(void *)&tv,sizeof(tv));
+ (void)setsockopt(sd,SOL_SOCKET,SO_SNDTIMEO,(void *)&tv,sizeof(tv));
+ }
/* if we had reachability problems with the server close the connection */
if (session->ld!=NULL)
{
@@ -621,7 +635,7 @@
and binds to the server. This returns an LDAP status code. */
static int do_open(MYLDAP_SESSION *session)
{
- int rc,rc2;
+ int rc;
int sd=-1;
int off=0;
/* check if the idle time for the connection has expired */
@@ -644,13 +658,7 @@
ldap_err2string(rc),(errno==0)?"":": ",
(errno==0)?"":strerror(errno));
if (session->ld!=NULL)
- {
- log_log(LOG_DEBUG,"ldap_unbind()");
- rc2=ldap_unbind(session->ld);
- session->ld=NULL;
- if (rc2!=LDAP_SUCCESS)
- log_log(LOG_WARNING,"ldap_unbind() failed: %s",ldap_err2string(rc2));
- }
+ do_close(session);
return rc;
}
else if (session->ld==NULL)
@@ -662,10 +670,7 @@
rc=do_set_options(session);
if (rc!=LDAP_SUCCESS)
{
- rc2=ldap_unbind(session->ld);
- session->ld=NULL;
- if (rc2!=LDAP_SUCCESS)
- log_log(LOG_WARNING,"ldap_unbind() failed: %s",ldap_err2string(rc2));
+ do_close(session);
return rc;
}
/* bind to the server */
@@ -679,10 +684,7 @@
nslcd_cfg->ldc_uris[session->current_uri].uri,
ldap_err2string(rc),(errno==0)?"":": ",
(errno==0)?"":strerror(errno));
- rc2=ldap_unbind(session->ld);
- session->ld=NULL;
- if (rc2!=LDAP_SUCCESS)
- log_log(LOG_WARNING,"ldap_unbind() failed: %s",ldap_err2string(rc2));
+ do_close(session);
return rc;
}
/* disable keepalive on the LDAP connection socket (why?) */
--
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: r1291 - in nss-pam-ldapd-0.7: . nslcd,
Commits of the nss-pam-ldapd project