Skip to content

Commit

Permalink
doveadm save: Fix using <file without panic
Browse files Browse the repository at this point in the history
When getting input with <file with Linux/epoll, it crashed with:

Panic: epoll_ctl(add, 0) failed: Operation not permitted (fd doesn't support epoll - instead of '<file', try 'cat file|')
  • Loading branch information
sirainen authored and cmouse committed Apr 24, 2018
1 parent 99e7753 commit affded8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/doveadm/doveadm-mail.c
Expand Up @@ -203,17 +203,19 @@ static void doveadm_mail_cmd_input_read(struct doveadm_mail_cmd_context *ctx)
struct timeout *to;

ioloop = io_loop_create();
io = io_add(ctx->cmd_input_fd, IO_READ,
doveadm_mail_cmd_input_input, ctx);
to = timeout_add(DOVEADM_MAIL_CMD_INPUT_TIMEOUT_MSECS,
doveadm_mail_cmd_input_timeout, ctx);
/* read the pending input from stream. */
/* Read the pending input from stream. Delay adding the IO in case
we're reading from a file. That would cause a panic with epoll. */
io_loop_set_running(ioloop);
doveadm_mail_cmd_input_input(ctx);
if (io_loop_is_running(ioloop))
if (io_loop_is_running(ioloop)) {
io = io_add(ctx->cmd_input_fd, IO_READ,
doveadm_mail_cmd_input_input, ctx);
to = timeout_add(DOVEADM_MAIL_CMD_INPUT_TIMEOUT_MSECS,
doveadm_mail_cmd_input_timeout, ctx);
io_loop_run(ioloop);
io_remove(&io);
timeout_remove(&to);
io_remove(&io);
timeout_remove(&to);
}
io_loop_destroy(&ioloop);

i_assert(ctx->cmd_input->eof);
Expand Down

0 comments on commit affded8

Please sign in to comment.