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))
;
}
#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;
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;
}
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++) {
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);
}