Skip to content

Commit

Permalink
cassandra: Don't use i_error() from non-main thread
Browse files Browse the repository at this point in the history
It will only cause crashes. This was done only if the internal
communication pipe couldn't be written to, which was pretty unlikely
to happen.
  • Loading branch information
sirainen committed Feb 21, 2017
1 parent 95d26b4 commit d9343f5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/lib-sql/driver-cassandra.c
Expand Up @@ -266,9 +266,16 @@ static void driver_cassandra_future_callback(CassFuture *future ATTR_UNUSED,
struct cassandra_callback *cb = context;

/* this isn't the main thread - communicate with main thread by
writing the callback id to the pipe */
if (write_full(cb->db->fd_pipe[1], &cb->id, sizeof(cb->id)) < 0)
i_error("cassandra: write(pipe) failed: %m");
writing the callback id to the pipe. note that we must not use
almost any dovecot functions here because most of them are using
data-stack, which isn't thread-safe. especially don't use
i_error() here. */
if (write_full(cb->db->fd_pipe[1], &cb->id, sizeof(cb->id)) < 0) {
const char *str = t_strdup_printf(
"cassandra: write(pipe) failed: %s\n",
strerror(errno));
(void)write_full(STDERR_FILENO, str, strlen(str));
}
}

static void cassandra_callback_run(struct cassandra_callback *cb)
Expand Down

0 comments on commit d9343f5

Please sign in to comment.