]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Userdb iteration optimization.
authorTimo Sirainen <tss@iki.fi>
Fri, 10 Oct 2014 21:01:09 +0000 (00:01 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 10 Oct 2014 21:01:09 +0000 (00:01 +0300)
Don't keep re-creating the timeout after iterating each user.

src/auth/auth-worker-server.c

index c7900e4ecc3f73e854bc114891c401d03c7de228..c7512bf0864b29cd7048c418d98000e9d5b6fa84 100644 (file)
@@ -46,6 +46,7 @@ struct auth_worker_connection {
        unsigned int received_error:1;
        unsigned int restart:1;
        unsigned int shutdown:1;
+       unsigned int timeout_pending_resume:1;
 };
 
 static ARRAY(struct auth_worker_connection *) connections = ARRAY_INIT;
@@ -278,6 +279,7 @@ static bool auth_worker_request_handle(struct auth_worker_connection *conn,
                timeout_reset(conn->to);
        } else {
                conn->request = NULL;
+               conn->timeout_pending_resume = FALSE;
                timeout_remove(&conn->to);
                conn->to = timeout_add(AUTH_WORKER_MAX_IDLE_SECS * 1000,
                                       auth_worker_idle_timeout, conn);
@@ -285,6 +287,7 @@ static bool auth_worker_request_handle(struct auth_worker_connection *conn,
        }
 
        if (!request->callback(line, request->context) && conn->io != NULL) {
+               conn->timeout_pending_resume = FALSE;
                timeout_remove(&conn->to);
                io_remove(&conn->io);
                return FALSE;
@@ -411,6 +414,7 @@ static void worker_input(struct auth_worker_connection *conn)
 
 static void worker_input_resume(struct auth_worker_connection *conn)
 {
+       conn->timeout_pending_resume = FALSE;
        timeout_remove(&conn->to);
        conn->to = timeout_add(AUTH_WORKER_LOOKUP_TIMEOUT_SECS * 1000,
                               auth_worker_call_timeout, conn);
@@ -456,9 +460,12 @@ void auth_worker_server_resume_input(struct auth_worker_connection *conn)
 {
        if (conn->io == NULL)
                conn->io = io_add(conn->fd, IO_READ, worker_input, conn);
-       if (conn->to != NULL)
-               timeout_remove(&conn->to);
-       conn->to = timeout_add_short(0, worker_input_resume, conn);
+       if (!conn->timeout_pending_resume) {
+               conn->timeout_pending_resume = TRUE;
+               if (conn->to != NULL)
+                       timeout_remove(&conn->to);
+               conn->to = timeout_add_short(0, worker_input_resume, conn);
+       }
 }
 
 void auth_worker_server_init(void)