From: Timo Sirainen Date: Thu, 21 Aug 2008 04:36:40 +0000 (+0300) Subject: ldap: Avoid kqueue/epoll errors when LDAP connection closes unexpectedly. X-Git-Tag: 1.2.alpha1~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=baf992882696ce085fa9122a559dbba8e627e19f;p=thirdparty%2Fdovecot%2Fcore.git ldap: Avoid kqueue/epoll errors when LDAP connection closes unexpectedly. --HG-- branch : HEAD --- diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 34cbc4887b..e394ef0c58 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -851,15 +851,18 @@ static void db_ldap_conn_close(struct ldap_connection *conn) conn->pending_count = 0; } - if (conn->io != NULL) - io_remove(&conn->io); - if (conn->ld != NULL) { ldap_unbind(conn->ld); conn->ld = NULL; } conn->fd = -1; + if (conn->io != NULL) { + /* the fd may have already been closed before ldap_unbind(), + so we'll have to use io_remove_closed(). */ + io_remove_closed(&conn->io); + } + if (aqueue_count(conn->request_queue) == 0) { if (conn->to != NULL) timeout_remove(&conn->to);