[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 5/8] io/channel-tls.c: make qio_channel_tls_shutdown thread-sa
From: |
Lukas Straub |
Subject: |
[PATCH v9 5/8] io/channel-tls.c: make qio_channel_tls_shutdown thread-safe |
Date: |
Wed, 28 Oct 2020 19:45:36 +0100 |
Make qio_channel_tls_shutdown thread-safe by using atomics when
accessing tioc->shutdown.
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
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 7ec8ceff2f..10d0bf59aa 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.20.1
pgppZDXEb1r4B.pgp
Description: OpenPGP digital signature
- [PATCH v9 0/8] Introduce 'yank' oob qmp command to recover from hanging qemu, Lukas Straub, 2020/10/28
- [PATCH v9 2/8] block/nbd.c: Add yank feature, Lukas Straub, 2020/10/28
- [PATCH v9 1/8] Introduce yank feature, Lukas Straub, 2020/10/28
- [PATCH v9 3/8] chardev/char-socket.c: Add yank feature, Lukas Straub, 2020/10/28
- [PATCH v9 4/8] migration: Add yank feature, Lukas Straub, 2020/10/28
- [PATCH v9 5/8] io/channel-tls.c: make qio_channel_tls_shutdown thread-safe,
Lukas Straub <=
- [PATCH v9 6/8] io: Document qmp oob suitability of qio_channel_shutdown and io_shutdown, Lukas Straub, 2020/10/28
- [PATCH v9 7/8] MAINTAINERS: Add myself as maintainer for yank feature, Lukas Straub, 2020/10/28
- [PATCH v9 8/8] tests/test-char.c: Wait for the chardev to connect in char_socket_client_dupid_test, Lukas Straub, 2020/10/28