From 50da38c0801b1b4498e50f830641c3cb53dad85e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 2 Aug 2016 20:09:49 +0300 Subject: [PATCH] imap: When un-hibernating, send notification to imap-hibernate process earlier. The initialization shouldn't take a long time, but there's really no need to keep imap-hibernate itself waiting (and maybe timing out) if it does. --- src/imap/imap-master-client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/imap/imap-master-client.c b/src/imap/imap-master-client.c index d562d1baae..e24c0a94ac 100644 --- a/src/imap/imap-master-client.c +++ b/src/imap/imap-master-client.c @@ -203,6 +203,10 @@ imap_master_client_input_args(struct connection *conn, const char *const *args, i_close_fd(&fd_client); return -1; } + /* Send a success notification before we start anything that lasts + potentially a long time. imap-hibernate process is waiting for us + to answer. Even if we fail later, we log the error anyway. */ + o_stream_send_str(conn->output, "+\n"); /* NOTE: before client_create_from_input() on failures we need to close fd_client, but afterward it gets closed by client_destroy() */ @@ -211,8 +215,6 @@ imap_master_client_input_args(struct connection *conn, const char *const *args, if (ret < 0) { i_error("imap-master(%s): Failed to create client: %s", input.username, error); - o_stream_send_str(conn->output, t_strdup_printf( - "-Failed to create client: %s\n", error)); master_service_client_connection_destroyed(master_service); i_close_fd(&fd_client); return -1; @@ -231,8 +233,6 @@ imap_master_client_input_args(struct connection *conn, const char *const *args, i_error("imap-master: Couldn't add %"PRIuSIZE_T " bytes to client's input stream", master_input.client_input->used); - o_stream_send_str(conn->output, - "-Couldn't add client input\n"); client_destroy(imap_client, "Client initialization failed"); return -1; } @@ -255,7 +255,6 @@ imap_master_client_input_args(struct connection *conn, const char *const *args, timeout_add(0, client_input, imap_client); } - o_stream_send_str(conn->output, "+\n"); imap_refresh_proctitle(); /* we'll always disconnect the client afterwards */ return -1;