Mercurial > dovecot > core-2.2
changeset 12917:cef23de90ff1
auth: If initial binding to LDAP server hangs, detect it and abort.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 04 Apr 2011 17:53:05 +0300 |
parents | 0ce50c22f84c |
children | 10ea7f598e11 |
files | src/auth/db-ldap.c |
diffstat | 1 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/db-ldap.c Sun Apr 03 06:42:48 2011 +0300 +++ b/src/auth/db-ldap.c Mon Apr 04 17:53:05 2011 +0300 @@ -456,6 +456,8 @@ return -1; } + if (conn->to != NULL) + timeout_remove(&conn->to); conn->conn_state = LDAP_CONN_STATE_BOUND_DEFAULT; while (db_ldap_request_queue_next(conn)) ; @@ -693,6 +695,14 @@ } #endif +static void ldap_connection_timeout(struct ldap_connection *conn) +{ + i_assert(conn->conn_state == LDAP_CONN_STATE_BINDING); + + i_error("LDAP: Initial binding to LDAP server timed out"); + db_ldap_conn_close(conn); +} + static int db_ldap_bind(struct ldap_connection *conn) { int msgid; @@ -714,6 +724,11 @@ conn->conn_state = LDAP_CONN_STATE_BINDING; conn->default_bind_msgid = msgid; + + if (conn->to != NULL) + timeout_remove(&conn->to); + conn->to = timeout_add(DB_LDAP_REQUEST_LOST_TIMEOUT_SECS*1000, + ldap_connection_timeout, conn); return 0; } @@ -928,6 +943,9 @@ conn->conn_state = LDAP_CONN_STATE_DISCONNECTED; conn->default_bind_msgid = -1; + if (conn->to != NULL) + timeout_remove(&conn->to); + if (conn->pending_count != 0) { requests = array_idx(&conn->request_array, 0); for (i = 0; i < conn->pending_count; i++) { @@ -951,10 +969,7 @@ io_remove_closed(&conn->io); } - if (aqueue_count(conn->request_queue) == 0) { - if (conn->to != NULL) - timeout_remove(&conn->to); - } else if (conn->to == NULL) { + if (aqueue_count(conn->request_queue) > 0) { conn->to = timeout_add(DB_LDAP_REQUEST_DISCONNECT_TIMEOUT_SECS * 1000/2, db_ldap_disconnect_timeout, conn); }