dovecot-2.2: lib-lda: Added lmtp-client to track timestamps when...

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 21 14:03:11 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/860af8c30c59
changeset: 18435:860af8c30c59
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 21 16:50:43 2015 +0300
description:
lib-lda: Added lmtp-client to track timestamps when various events happen.

diffstat:

 src/lib-lda/lmtp-client.c |  13 +++++++++++++
 src/lib-lda/lmtp-client.h |  10 ++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diffs (81 lines):

diff -r 881ab9a0dc2e -r 860af8c30c59 src/lib-lda/lmtp-client.c
--- a/src/lib-lda/lmtp-client.c	Tue Apr 21 14:08:12 2015 +0300
+++ b/src/lib-lda/lmtp-client.c	Tue Apr 21 16:50:43 2015 +0300
@@ -71,6 +71,7 @@
 	unsigned int rcpt_next_send_idx;
 	struct istream *data_input;
 	unsigned char output_last;
+	struct lmtp_client_times times;
 
 	unsigned int running:1;
 	unsigned int xclient_sent:1;
@@ -392,6 +393,8 @@
 	}
 	o_stream_nsend(client->output, ".\r\n", 3);
 	client->output_finished = TRUE;
+	io_loop_time_refresh();
+	client->times.data_sent = ioloop_timeval;
 	return 0;
 }
 
@@ -507,6 +510,7 @@
 				"451 4.5.0 Received invalid greeting: %s", line));
 			return -1;
 		}
+		client->times.banner_received = ioloop_timeval;
 		lmtp_client_send_handshake(client);
 		client->input_state = LMTP_INPUT_STATE_LHLO;
 		break;
@@ -561,6 +565,7 @@
 			return -1;
 		}
 		client->input_state++;
+		client->times.data_started = ioloop_timeval;
 		if (client->data_header != NULL)
 			o_stream_nsend_str(client->output, client->data_header);
 		if (lmtp_client_send_data(client) < 0)
@@ -662,6 +667,8 @@
 {
 	i_assert(client->fd == -1);
 
+	client->times.connect_started = ioloop_timeval;
+
 	client->fd = net_connect_ip(&client->ip, client->port, NULL);
 	if (client->fd == -1) {
 		i_error("lmtp client: connect(%s, %u) failed: %m",
@@ -879,3 +886,9 @@
 	client->data_output_callback = callback;
 	client->data_output_context = context;
 }
+
+const struct lmtp_client_times *
+lmtp_client_get_times(struct lmtp_client *client)
+{
+	return &client->times;
+}
diff -r 881ab9a0dc2e -r 860af8c30c59 src/lib-lda/lmtp-client.h
--- a/src/lib-lda/lmtp-client.h	Tue Apr 21 14:08:12 2015 +0300
+++ b/src/lib-lda/lmtp-client.h	Tue Apr 21 16:50:43 2015 +0300
@@ -26,6 +26,13 @@
 	const char *dsn_orcpt;
 };
 
+struct lmtp_client_times {
+	struct timeval connect_started;
+	struct timeval banner_received;
+	struct timeval data_started;
+	struct timeval data_sent;
+};
+
 struct lmtp_client_settings {
 	const char *my_hostname;
 	/* The whole MAIL FROM line, including parameters */
@@ -93,5 +100,8 @@
 void lmtp_client_set_data_output_callback(struct lmtp_client *client,
 					  void (*callback)(void *),
 					  void *context);
+/* Return LMTP client statistics. */
+const struct lmtp_client_times *
+lmtp_client_get_times(struct lmtp_client *client);
 
 #endif


More information about the dovecot-cvs mailing list