# HG changeset patch # User Timo Sirainen # Date 1487670955 -7200 # Node ID e04d881da1fb78aa4fef7b2afde2c0ce34b8ca8e # Parent 79d9124f8c8bd31222f4abc36d7aa0528ef5bbd7 cassandra: Don't use i_error() from non-main thread 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. diff -r 79d9124f8c8b -r e04d881da1fb src/lib-sql/driver-cassandra.c --- a/src/lib-sql/driver-cassandra.c Tue Feb 21 13:08:59 2017 +0200 +++ b/src/lib-sql/driver-cassandra.c Tue Feb 21 11:55:55 2017 +0200 @@ -266,9 +266,16 @@ 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)