dovecot-1.1: ldap: If first request is over 60 seconds old while...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Apr 29 19:41:02 EEST 2009
details: http://hg.dovecot.org/dovecot-1.1/rev/f28d0ec6ec09
changeset: 8254:f28d0ec6ec09
user: Timo Sirainen <tss at iki.fi>
date: Wed Apr 29 12:40:24 2009 -0400
description:
ldap: If first request is over 60 seconds old while a new request comes, reconnect.
diffstat:
1 file changed, 31 insertions(+), 10 deletions(-)
src/auth/db-ldap.c | 41 +++++++++++++++++++++++++++++++----------
diffs (58 lines):
diff -r 8e597c226093 -r f28d0ec6ec09 src/auth/db-ldap.c
--- a/src/auth/db-ldap.c Tue Apr 28 17:00:01 2009 -0400
+++ b/src/auth/db-ldap.c Wed Apr 29 12:40:24 2009 -0400
@@ -380,6 +380,36 @@ static bool db_ldap_request_queue_next(s
}
}
+static bool
+db_ldap_check_limits(struct ldap_connection *conn, struct ldap_request *request)
+{
+ struct ldap_request *const *first_requestp;
+ unsigned int count;
+ time_t secs_diff;
+
+ count = aqueue_count(conn->request_queue);
+ if (count == 0)
+ return TRUE;
+
+ first_requestp = array_idx(&conn->request_array,
+ aqueue_idx(conn->request_queue, 0));
+ secs_diff = ioloop_time - (*first_requestp)->create_time;
+ if (secs_diff > DB_LDAP_REQUEST_LOST_TIMEOUT_SECS) {
+ auth_request_log_error(request->auth_request, "ldap",
+ "Connection appears to be hanging, reconnecting");
+ ldap_conn_reconnect(conn);
+ return TRUE;
+ }
+ if (conn->request_queue->full && count >= DB_LDAP_MAX_QUEUE_SIZE) {
+ /* Queue is full already, fail this request */
+ auth_request_log_error(request->auth_request, "ldap",
+ "Request queue is full (oldest added %d secs ago)",
+ (int)secs_diff);
+ return FALSE;
+ }
+ return TRUE;
+}
+
void db_ldap_request(struct ldap_connection *conn,
struct ldap_request *request)
{
@@ -388,16 +418,7 @@ void db_ldap_request(struct ldap_connect
request->msgid = -1;
request->create_time = ioloop_time;
- if (conn->request_queue->full &&
- aqueue_count(conn->request_queue) >= DB_LDAP_MAX_QUEUE_SIZE) {
- /* Queue is full already, fail this request */
- struct ldap_request *const *first_requestp;
-
- first_requestp = array_idx(&conn->request_array,
- aqueue_idx(conn->request_queue, 0));
- auth_request_log_error(request->auth_request, "ldap",
- "Request queue is full (oldest added %d secs ago)",
- (int)(time(NULL) - (*first_requestp)->create_time));
+ if (!db_ldap_check_limits(conn, request)) {
request->callback(conn, request, NULL);
return;
}
More information about the dovecot-cvs
mailing list