dovecot-2.2: indexer: Try to always flush as many requests from ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 3 19:28:27 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/a5d5d2dd6aea
changeset: 18823:a5d5d2dd6aea
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 03 22:26:05 2015 +0300
description:
indexer: Try to always flush as many requests from queue as possible.
I don't think this changes the behavior much. It's mainly a code cleanup.

diffstat:

 src/indexer/indexer.c |  35 ++++++++++-------------------------
 1 files changed, 10 insertions(+), 25 deletions(-)

diffs (57 lines):

diff -r 165564cc0e0e -r a5d5d2dd6aea src/indexer/indexer.c
--- a/src/indexer/indexer.c	Wed Jun 03 22:25:28 2015 +0300
+++ b/src/indexer/indexer.c	Wed Jun 03 22:26:05 2015 +0300
@@ -53,7 +53,7 @@
 	worker_connection_request(conn, request, wrequest);
 }
 
-static void queue_handle_existing_user_requests(struct indexer_queue *queue)
+static void queue_try_send_more(struct indexer_queue *queue)
 {
 	struct worker_connection *conn;
 	struct indexer_request *request;
@@ -61,35 +61,20 @@
 	while ((request = indexer_queue_request_peek(queue)) != NULL) {
 		conn = worker_pool_find_username_connection(worker_pool,
 							    request->username);
-		if (conn == NULL)
-			break;
-
+		if (conn != NULL) {
+			/* there is already a worker handling this user.
+			   it must be the one doing the indexing. use the same
+			   connection for sending this next request. */
+		} else {
+			/* try to find an empty worker */
+			if (!worker_pool_get_connection(worker_pool, &conn))
+				break;
+		}
 		indexer_queue_request_remove(queue);
-		/* there is already a worker handling this user.
-		   it must be the one doing the indexing. */
 		worker_send_request(conn, request);
 	}
 }
 
-static void queue_try_send_more(struct indexer_queue *queue)
-{
-	struct worker_connection *conn;
-	struct indexer_request *request;
-
-	queue_handle_existing_user_requests(queue);
-
-	request = indexer_queue_request_peek(queue);
-	if (request == NULL)
-		return;
-
-	/* okay, we have a request for a new user. */
-	if (!worker_pool_get_connection(worker_pool, &conn))
-		return;
-
-	indexer_queue_request_remove(queue);
-	worker_send_request(conn, request);
-}
-
 static void queue_listen_callback(struct indexer_queue *queue)
 {
 	queue_try_send_more(queue);


More information about the dovecot-cvs mailing list