From: Timo Sirainen Date: Tue, 21 Feb 2017 09:55:55 +0000 (+0200) Subject: cassandra: Don't use i_error() from non-main thread X-Git-Tag: 2.2.29.rc1~256 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9be49acfa4ee4d05b212d49064b7138f05a18296;p=thirdparty%2Fdovecot%2Fcore.git 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 --git a/src/lib-sql/driver-cassandra.c b/src/lib-sql/driver-cassandra.c index b158351f9c..d6c6fb821c 100644 --- a/src/lib-sql/driver-cassandra.c +++ b/src/lib-sql/driver-cassandra.c @@ -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)