#define IMAP_UNHIBERNATE_RETRY_MSECS 100
#define IMAP_CLIENT_BUFFER_FULL_ERROR "Client output buffer is full"
+#define IMAP_CLIENT_UNHIBERNATE_ERROR "Failed to unhibernate client"
enum imap_client_input_state {
IMAP_CLIENT_INPUT_STATE_UNKNOWN,
imap_client_destroy(_client, reason);
}
+static void
+imap_client_unhibernate_failed(struct imap_client **_client, const char *error)
+{
+ struct imap_client *client = *_client;
+
+ e_error(client->event, IMAP_CLIENT_UNHIBERNATE_ERROR": %s", error);
+ imap_client_destroy(_client, IMAP_CLIENT_UNHIBERNATE_ERROR);
+}
+
static void
imap_client_parse_userdb_fields(struct imap_client *client,
const char **auth_user_r)
/* send the fd first */
ret = fd_send(o_stream_get_fd(output), client->fd, str_data(str), 1);
if (ret < 0) {
- e_error(client->event, "fd_send(%s) failed: %m",
- o_stream_get_name(output));
- imap_client_destroy(&client, "Failed to recreate imap process");
+ const char *error = t_strdup_printf(
+ "fd_send(%s) failed: %m", o_stream_get_name(output));
+ imap_client_unhibernate_failed(&client, error);
return;
}
i_assert(ret > 0);
if (line[0] != '+') {
/* failed - FIXME: retry later? */
- imap_client_destroy(&client, t_strdup_printf(
- "Failed to recreate imap process: %s", line+1));
+ imap_client_unhibernate_failed(&client, line+1);
} else {
imap_client_destroy(&client, NULL);
}
return TRUE;
} else if (ret < 0 || imap_move_has_reached_timeout(client)) {
/* failed to connect to the imap-master socket */
- e_error(client->event, "Failed to unhibernate client: %s", error);
- imap_client_destroy(&client, error);
+ imap_client_unhibernate_failed(&client, error);
return TRUE;
}