dovecot-2.2: auth worker: Log a warning if master disconnects us...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Mar 12 10:26:27 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/4856ff35f7be
changeset: 17156:4856ff35f7be
user: Timo Sirainen <tss at iki.fi>
date: Wed Mar 12 12:19:09 2014 +0200
description:
auth worker: Log a warning if master disconnects us while handling a long request.
diffstat:
src/auth/auth-worker-client.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diffs (95 lines):
diff -r 8df5fc361103 -r 4856ff35f7be src/auth/auth-worker-client.c
--- a/src/auth/auth-worker-client.c Wed Mar 12 11:53:49 2014 +0200
+++ b/src/auth/auth-worker-client.c Wed Mar 12 12:19:09 2014 +0200
@@ -16,6 +16,7 @@
#include <stdlib.h>
+#define AUTH_WORKER_WARN_DISCONNECTED_LONG_CMD_SECS 30
#define OUTBUF_THROTTLE_SIZE (1024*10)
#define CLIENT_STATE_HANDSHAKE "handshaking"
@@ -32,6 +33,7 @@
struct istream *input;
struct ostream *output;
struct timeout *to_idle;
+ time_t cmd_start;
unsigned int version_received:1;
unsigned int dbhash_received:1;
@@ -103,11 +105,20 @@
}
static void auth_worker_send_reply(struct auth_worker_client *client,
+ struct auth_request *request,
string_t *str)
{
+ time_t cmd_duration = time(NULL) - client->cmd_start;
+
if (worker_restart_request)
o_stream_nsend_str(client->output, "RESTART\n");
o_stream_nsend(client->output, str_data(str), str_len(str));
+ if (o_stream_nfinish(client->output) < 0 && request != NULL &&
+ cmd_duration > AUTH_WORKER_WARN_DISCONNECTED_LONG_CMD_SECS) {
+ i_warning("Auth master disconnected us while handling "
+ "request for %s for %ld secs",
+ request->user, (long)cmd_duration);
+ }
}
static void
@@ -150,7 +161,7 @@
reply_append_extra_fields(str, request);
}
str_append_c(str, '\n');
- auth_worker_send_reply(client, str);
+ auth_worker_send_reply(client, request, str);
auth_request_unref(&request);
auth_worker_client_check_throttle(client);
@@ -231,7 +242,7 @@
reply_append_extra_fields(str, request);
}
str_append_c(str, '\n');
- auth_worker_send_reply(client, str);
+ auth_worker_send_reply(client, request, str);
auth_request_unref(&request);
auth_worker_client_check_throttle(client);
@@ -293,7 +304,7 @@
str = t_str_new(64);
str_printfa(str, "%u\t%s\n", request->id, success ? "OK" : "FAIL");
- auth_worker_send_reply(client, str);
+ auth_worker_send_reply(client, request, str);
auth_request_unref(&request);
auth_worker_client_check_throttle(client);
@@ -361,7 +372,7 @@
}
str_append_c(str, '\n');
- auth_worker_send_reply(client, str);
+ auth_worker_send_reply(client, auth_request, str);
auth_request_unref(&auth_request);
auth_worker_client_check_throttle(client);
@@ -449,7 +460,7 @@
str_printfa(str, "%u\tFAIL\n", ctx->auth_request->id);
else
str_printfa(str, "%u\tOK\n", ctx->auth_request->id);
- auth_worker_send_reply(client, str);
+ auth_worker_send_reply(client, NULL, str);
client->io = io_add(client->fd, IO_READ, auth_worker_input, client);
auth_worker_client_set_idle_timeout(client);
@@ -584,6 +595,9 @@
return FALSE;
}
+ io_loop_time_refresh();
+ client->cmd_start = ioloop_time;
+
auth_worker_refresh_proctitle(args[1]);
if (strcmp(args[1], "PASSV") == 0)
ret = auth_worker_handle_passv(client, id, args + 2);
More information about the dovecot-cvs
mailing list