dovecot-2.2: fts: Send session ID to indexer and indexer-worker ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 21 14:02:35 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/250d85e784d1
changeset: 19170:250d85e784d1
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 21 17:01:05 2015 +0300
description:
fts: Send session ID to indexer and indexer-worker for logging purposes.

diffstat:

 src/indexer/indexer-client.c    |   7 +++++--
 src/indexer/indexer-queue.c     |  10 +++++++---
 src/indexer/indexer-queue.h     |   4 +++-
 src/indexer/master-connection.c |   9 +++++----
 src/indexer/worker-connection.c |   3 +++
 src/plugins/fts/fts-indexer.c   |   5 +++--
 src/plugins/fts/fts-storage.c   |   5 ++++-
 7 files changed, 30 insertions(+), 13 deletions(-)

diffs (176 lines):

diff -r f205f3d56093 -r 250d85e784d1 src/indexer/indexer-client.c
--- a/src/indexer/indexer-client.c	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/indexer/indexer-client.c	Mon Sep 21 17:01:05 2015 +0300
@@ -67,9 +67,10 @@
 			     const char *const *args, const char **error_r)
 {
 	struct indexer_client_request *ctx = NULL;
+	const char *session_id = NULL;
 	unsigned int tag, max_recent_msgs;
 
-	/* <tag> <user> <mailbox> [<max_recent_msgs>] */
+	/* <tag> <user> <mailbox> [<max_recent_msgs> [<session ID>]] */
 	if (str_array_length(args) < 3) {
 		*error_r = "Wrong parameter count";
 		return -1;
@@ -83,6 +84,8 @@
 	else if (str_to_uint(args[3], &max_recent_msgs) < 0) {
 		*error_r = "Invalid max_recent_msgs";
 		return -1;
+	} else {
+		session_id = args[4];
 	}
 
 	if (tag != 0) {
@@ -93,7 +96,7 @@
 	}
 
 	indexer_queue_append(client->queue, append, args[1], args[2],
-			     max_recent_msgs, ctx);
+			     session_id, max_recent_msgs, ctx);
 	o_stream_nsend_str(client->output, t_strdup_printf("%u\tOK\n", tag));
 	return 0;
 }
diff -r f205f3d56093 -r 250d85e784d1 src/indexer/indexer-queue.c
--- a/src/indexer/indexer-queue.c	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/indexer/indexer-queue.c	Mon Sep 21 17:01:05 2015 +0300
@@ -82,6 +82,7 @@
 static struct indexer_request *
 indexer_queue_append_request(struct indexer_queue *queue, bool append,
 			     const char *username, const char *mailbox,
+			     const char *session_id,
 			     unsigned int max_recent_msgs, void *context)
 {
 	struct indexer_request *request;
@@ -91,6 +92,7 @@
 		request = i_new(struct indexer_request, 1);
 		request->username = i_strdup(username);
 		request->mailbox = i_strdup(mailbox);
+		request->session_id = i_strdup(session_id);
 		request->max_recent_msgs = max_recent_msgs;
 		request_add_context(request, context);
 		hash_table_insert(queue->requests, request, request);
@@ -130,12 +132,14 @@
 
 void indexer_queue_append(struct indexer_queue *queue, bool append,
 			  const char *username, const char *mailbox,
-			  unsigned int max_recent_msgs, void *context)
+			  const char *session_id, unsigned int max_recent_msgs,
+			  void *context)
 {
 	struct indexer_request *request;
 
 	request = indexer_queue_append_request(queue, append, username, mailbox,
-					       max_recent_msgs, context);
+					       session_id, max_recent_msgs,
+					       context);
 	request->index = TRUE;
 	indexer_queue_append_finish(queue);
 }
@@ -147,7 +151,7 @@
 	struct indexer_request *request;
 
 	request = indexer_queue_append_request(queue, TRUE, username, mailbox,
-					       0, context);
+					       NULL, 0, context);
 	request->optimize = TRUE;
 	indexer_queue_append_finish(queue);
 }
diff -r f205f3d56093 -r 250d85e784d1 src/indexer/indexer-queue.h
--- a/src/indexer/indexer-queue.h	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/indexer/indexer-queue.h	Mon Sep 21 17:01:05 2015 +0300
@@ -8,6 +8,7 @@
 
 	char *username;
 	char *mailbox;
+	char *session_id;
 	unsigned int max_recent_msgs;
 
 	/* index messages in this mailbox */
@@ -38,7 +39,8 @@
 	
 void indexer_queue_append(struct indexer_queue *queue, bool append,
 			  const char *username, const char *mailbox,
-			  unsigned int max_recent_msgs, void *context);
+			  const char *session_id, unsigned int max_recent_msgs,
+			  void *context);
 void indexer_queue_append_optimize(struct indexer_queue *queue,
 				   const char *username, const char *mailbox,
 				   void *context);
diff -r f205f3d56093 -r 250d85e784d1 src/indexer/master-connection.c
--- a/src/indexer/master-connection.c	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/indexer/master-connection.c	Mon Sep 21 17:01:05 2015 +0300
@@ -201,9 +201,9 @@
 	unsigned int max_recent_msgs;
 	int ret;
 
-	/* <username> <mailbox> <max_recent_msgs> [i][o] */
-	if (str_array_length(args) != 4 ||
-	    str_to_uint(args[2], &max_recent_msgs) < 0 || args[3][0] == '\0') {
+	/* <username> <mailbox> <session ID> <max_recent_msgs> [i][o] */
+	if (str_array_length(args) != 5 ||
+	    str_to_uint(args[3], &max_recent_msgs) < 0 || args[4][0] == '\0') {
 		i_error("Invalid input from master: %s", line);
 		return -1;
 	}
@@ -212,6 +212,7 @@
 	input.module = "mail";
 	input.service = "indexer-worker";
 	input.username = args[0];
+	input.session_id = args[2][0] == '\0' ? NULL : args[2];
 
 	if (mail_storage_service_lookup_next(conn->storage_service, &input,
 					     &service_user, &user, &error) <= 0) {
@@ -220,7 +221,7 @@
 	} else {
 		indexer_worker_refresh_proctitle(user->username, args[1], 0, 0);
 		ret = index_mailbox(conn, user, args[1],
-				    max_recent_msgs, args[3]);
+				    max_recent_msgs, args[4]);
 		indexer_worker_refresh_proctitle(NULL, NULL, 0, 0);
 		mail_user_unref(&user);
 		mail_storage_service_user_free(&service_user);
diff -r f205f3d56093 -r 250d85e784d1 src/indexer/worker-connection.c
--- a/src/indexer/worker-connection.c	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/indexer/worker-connection.c	Mon Sep 21 17:01:05 2015 +0300
@@ -241,6 +241,9 @@
 		str_append_tabescaped(str, request->username);
 		str_append_c(str, '\t');
 		str_append_tabescaped(str, request->mailbox);
+		str_append_c(str, '\t');
+		if (request->session_id != NULL)
+			str_append_tabescaped(str, request->session_id);
 		str_printfa(str, "\t%u\t", request->max_recent_msgs);
 		if (request->index)
 			str_append_c(str, 'i');
diff -r f205f3d56093 -r 250d85e784d1 src/plugins/fts/fts-indexer.c
--- a/src/plugins/fts/fts-indexer.c	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/plugins/fts/fts-indexer.c	Mon Sep 21 17:01:05 2015 +0300
@@ -113,9 +113,10 @@
 		return 0;
 	}
 
-	cmd = t_strdup_printf("PREPEND\t1\t%s\t%s\n",
+	cmd = t_strdup_printf("PREPEND\t1\t%s\t%s\t0\t%s\n",
 			      str_tabescape(box->storage->user->username),
-			      str_tabescape(box->vname));
+			      str_tabescape(box->vname),
+			      str_tabescape(box->storage->user->session_id));
 	fd = fts_indexer_cmd(box->storage->user, cmd, &path);
 	if (fd == -1)
 		return -1;
diff -r f205f3d56093 -r 250d85e784d1 src/plugins/fts/fts-storage.c
--- a/src/plugins/fts/fts-storage.c	Mon Sep 21 16:36:05 2015 +0300
+++ b/src/plugins/fts/fts-storage.c	Mon Sep 21 17:01:05 2015 +0300
@@ -612,7 +612,10 @@
 	str_append_tabescaped(str, user->username);
 	str_append_c(str, '\t');
 	str_append_tabescaped(str, box->vname);
-	str_printfa(str, "\t%u\n", max_recent_msgs);
+	str_printfa(str, "\t%u", max_recent_msgs);
+	str_append_c(str, '\t');
+	str_append_tabescaped(str, box->storage->user->session_id);
+	str_append_c(str, '\n');
 	if (write_full(fd, str_data(str), str_len(str)) < 0)
 		i_error("write(%s) failed: %m", path);
 	i_close_fd(&fd);


More information about the dovecot-cvs mailing list