From e4d2bfb1700db663ddda448368f06570f7f81970 Mon Sep 17 00:00:00 2001 From: Lukas Straub Date: Mon, 28 Dec 2020 16:08:55 +0100 Subject: [PATCH] io/channel-tls.c: make qio_channel_tls_shutdown thread-safe MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make qio_channel_tls_shutdown thread-safe by using atomics when accessing tioc->shutdown. Signed-off-by: Lukas Straub Acked-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrangé Message-Id: <5bd8733f583f3558b32250fd0eb576b7aa756485.1609167865.git.lukasstraub2@web.de> Signed-off-by: Markus Armbruster --- io/channel-tls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/io/channel-tls.c b/io/channel-tls.c index 388f019977..2ae1b92fc0 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -23,6 +23,7 @@ #include "qemu/module.h" #include "io/channel-tls.h" #include "trace.h" +#include "qemu/atomic.h" static ssize_t qio_channel_tls_write_handler(const char *buf, @@ -277,7 +278,8 @@ static ssize_t qio_channel_tls_readv(QIOChannel *ioc, return QIO_CHANNEL_ERR_BLOCK; } } else if (errno == ECONNABORTED && - (tioc->shutdown & QIO_CHANNEL_SHUTDOWN_READ)) { + (qatomic_load_acquire(&tioc->shutdown) & + QIO_CHANNEL_SHUTDOWN_READ)) { return 0; } @@ -361,7 +363,7 @@ static int qio_channel_tls_shutdown(QIOChannel *ioc, { QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc); - tioc->shutdown |= how; + qatomic_or(&tioc->shutdown, how); return qio_channel_shutdown(tioc->master, how, errp); } -- 2.11.4.GIT