Skip to content

Commit

Permalink
io/channel-tls.c: make qio_channel_tls_shutdown thread-safe
Browse files Browse the repository at this point in the history
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>
Message-Id: <5bd8733f583f3558b32250fd0eb576b7aa756485.1609167865.git.lukasstraub2@web.de>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
  • Loading branch information
Lukey3332 authored and Markus Armbruster committed Jan 13, 2021
1 parent b5eea99 commit e4d2bfb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions io/channel-tls.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit e4d2bfb

Please sign in to comment.