aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto/tlssession.c3
-rw-r--r--include/io/channel-tls.h1
-rw-r--r--include/io/channel.h6
-rw-r--r--io/channel-tls.c5
4 files changed, 12 insertions, 3 deletions
diff --git a/crypto/tlssession.c b/crypto/tlssession.c
index 2f28fa7f71..0dedd4af52 100644
--- a/crypto/tlssession.c
+++ b/crypto/tlssession.c
@@ -473,6 +473,9 @@ qcrypto_tls_session_read(QCryptoTLSSession *session,
case GNUTLS_E_INTERRUPTED:
errno = EINTR;
break;
+ case GNUTLS_E_PREMATURE_TERMINATION:
+ errno = ECONNABORTED;
+ break;
default:
errno = EIO;
break;
diff --git a/include/io/channel-tls.h b/include/io/channel-tls.h
index 87fcaf9146..fdbdf12feb 100644
--- a/include/io/channel-tls.h
+++ b/include/io/channel-tls.h
@@ -48,6 +48,7 @@ struct QIOChannelTLS {
QIOChannel parent;
QIOChannel *master;
QCryptoTLSSession *session;
+ QIOChannelShutdown shutdown;
};
/**
diff --git a/include/io/channel.h b/include/io/channel.h
index e8cdadb0b0..da2f138200 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -51,9 +51,9 @@ enum QIOChannelFeature {
typedef enum QIOChannelShutdown QIOChannelShutdown;
enum QIOChannelShutdown {
- QIO_CHANNEL_SHUTDOWN_BOTH,
- QIO_CHANNEL_SHUTDOWN_READ,
- QIO_CHANNEL_SHUTDOWN_WRITE,
+ QIO_CHANNEL_SHUTDOWN_READ = 1,
+ QIO_CHANNEL_SHUTDOWN_WRITE = 2,
+ QIO_CHANNEL_SHUTDOWN_BOTH = 3,
};
typedef gboolean (*QIOChannelFunc)(QIOChannel *ioc,
diff --git a/io/channel-tls.c b/io/channel-tls.c
index 9628e6fa47..c98ead21b0 100644
--- a/io/channel-tls.c
+++ b/io/channel-tls.c
@@ -275,6 +275,9 @@ static ssize_t qio_channel_tls_readv(QIOChannel *ioc,
} else {
return QIO_CHANNEL_ERR_BLOCK;
}
+ } else if (errno == ECONNABORTED &&
+ (tioc->shutdown & QIO_CHANNEL_SHUTDOWN_READ)) {
+ return 0;
}
error_setg_errno(errp, errno,
@@ -357,6 +360,8 @@ static int qio_channel_tls_shutdown(QIOChannel *ioc,
{
QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc);
+ tioc->shutdown |= how;
+
return qio_channel_shutdown(tioc->master, how, errp);
}