struct ostream *output;
struct ostream *log_out;
struct ssl_iostream *ssl_iostream;
+ struct ioloop *ioloop;
bool handshaked:1;
bool preauthenticated:1;
if (!log_recursing && conn != NULL &&
conn->log_out != NULL) T_BEGIN {
+ struct ioloop *prev_ioloop = current_ioloop;
struct ostream *log_out = conn->log_out;
char c;
const char *ptr, *start;
any of the following code causes logging */
log_recursing = TRUE;
+ /* since we can get here from just about anywhere, make sure
+ the log ostream uses the connection's ioloop. */
+ io_loop_set_current(conn->ioloop);
+
c = doveadm_log_type_to_char(ctx->type);
corked = o_stream_is_corked(log_out);
o_stream_uncork(log_out);
if (corked)
o_stream_cork(log_out);
+ io_loop_set_current(prev_ioloop);
log_recursing = FALSE;
} T_END;
int argc, const char *const argv[],
struct doveadm_cmd_context *cctx)
{
- struct ioloop *ioloop, *prev_ioloop = current_ioloop;
+ struct ioloop *prev_ioloop = current_ioloop;
const struct doveadm_cmd *cmd = NULL;
const struct doveadm_mail_cmd *mail_cmd;
struct doveadm_mail_cmd_context *mctx;
/* some commands will want to call io_loop_run(), but we're already
running one and we can't call the original one recursively, so
create a new ioloop. */
- ioloop = io_loop_create();
+ conn->ioloop = io_loop_create();
if (cmd_ver2 != NULL)
doveadm_cmd_server_run_ver2(conn, argc, argv, cctx);
o_stream_switch_ioloop(conn->output);
if (conn->log_out != NULL)
o_stream_switch_ioloop(conn->log_out);
- io_loop_set_current(ioloop);
- io_loop_destroy(&ioloop);
+ io_loop_set_current(conn->ioloop);
+ io_loop_destroy(&conn->ioloop);
/* clear all headers */
doveadm_print_deinit();