From 30cce6d17951e5832982c0e3f042c8b75c6d5ca9 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Tue, 29 Dec 2009 12:44:56 +0000 Subject: some small simplifcations and clarifications git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1046 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/cfg.h | 4 ++-- nslcd/myldap.c | 23 +++++++---------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/nslcd/cfg.h b/nslcd/cfg.h index 02a8152..8c74276 100644 --- a/nslcd/cfg.h +++ b/nslcd/cfg.h @@ -70,9 +70,9 @@ enum ldap_map_selector struct myldap_uri { char *uri; - /* timestamp of last ok search */ + /* time of last successful operation */ time_t lastok; - /* timestamp of last ok search */ + /* time of last failed operation */ time_t lastfail; }; diff --git a/nslcd/myldap.c b/nslcd/myldap.c index 8118464..929cd23 100644 --- a/nslcd/myldap.c +++ b/nslcd/myldap.c @@ -569,7 +569,6 @@ static void do_close(MYLDAP_SESSION *session) static void myldap_session_check(MYLDAP_SESSION *session) { int i; - int runningsearches=0; time_t current_time; /* check parameters */ if (!is_valid_session(session)) @@ -581,24 +580,16 @@ static void myldap_session_check(MYLDAP_SESSION *session) /* check if we should time out the connection */ if ((session->ld!=NULL)&&(nslcd_cfg->ldc_idle_timelimit>0)) { - /* check if we have any running searches */ + /* if we have any running searches, don't time out */ for (i=0;isearches[i]!=NULL)&&(session->searches[i]->valid)) - { - runningsearches=1; - break; - } - } - /* only consider timeout if we have no running searches */ - if (!runningsearches) + return; + /* consider timeout (there are no running searches) */ + time(¤t_time); + if ((session->lastactivity+nslcd_cfg->ldc_idle_timelimit)lastactivity+nslcd_cfg->ldc_idle_timelimit)