Index: src/auth/db-ldap.c =================================================================== RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.c,v retrieving revision 1.41.2.18 diff -u -r1.41.2.18 db-ldap.c --- src/auth/db-ldap.c 19 Jan 2007 15:27:42 -0000 1.41.2.18 +++ src/auth/db-ldap.c 2 Apr 2007 14:05:31 -0000 @@ -41,6 +41,8 @@ # define LDAP_OPT_SUCCESS LDAP_SUCCESS #endif +#define LDAP_TIMEOUT_SECS (60*5) + #define DEF(type, name) \ { type, #name, offsetof(struct ldap_settings, name) } @@ -307,6 +309,8 @@ LDAPMessage *res; int ret, msgid; + conn->last_io = ioloop_time; + for (;;) { if (conn->ld == NULL) return; @@ -472,6 +476,15 @@ net_set_nonblock(conn->fd, TRUE); } +static void ldap_timeout(void *context) +{ + struct ldap_connection *conn = context; + + if (conn->last_io + LDAP_TIMEOUT_SECS < ioloop_time && + hash_size(conn->requests) == 0) + ldap_conn_close(conn, FALSE); +} + int db_ldap_connect(struct ldap_connection *conn) { unsigned int ldap_version; @@ -560,6 +573,7 @@ } conn->io = io_add(conn->fd, IO_READ, ldap_input, conn); + conn->to = timeout_add(1000, ldap_timeout, conn); return 0; } @@ -592,6 +606,8 @@ conn->connected = FALSE; conn->binding = FALSE; + if (conn->to != NULL) + timeout_remove(&conn->to); if (conn->io != NULL) io_remove(&conn->io); Index: src/auth/db-ldap.h =================================================================== RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.h,v retrieving revision 1.20.2.9 diff -u -r1.20.2.9 db-ldap.h --- src/auth/db-ldap.h 19 Jan 2007 15:19:29 -0000 1.20.2.9 +++ src/auth/db-ldap.h 2 Apr 2007 14:05:31 -0000 @@ -57,6 +57,8 @@ LDAP *ld; int fd; /* only set when connected/connecting */ struct io *io; + struct timeout *to; + time_t last_io; struct hash_table *requests; struct ldap_request *delayed_requests_head, *delayed_requests_tail;