changeset 8101:06cb6f9d3054 HEAD

ldap: Avoid kqueue/epoll errors when LDAP connection closes unexpectedly.
author Timo Sirainen <tss@iki.fi>
date Thu, 21 Aug 2008 07:36:40 +0300
parents 83aef3a6c0a3
children 277aadb0ef8c
files src/auth/db-ldap.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/db-ldap.c	Thu Aug 21 07:35:59 2008 +0300
+++ b/src/auth/db-ldap.c	Thu Aug 21 07:36:40 2008 +0300
@@ -851,15 +851,18 @@
 		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);