From 0e3073f4022de1a29ee0ce8758827430b2ae436a Mon Sep 17 00:00:00 2001 From: Yunye Pu Date: Tue, 31 Aug 2021 13:29:41 +0800 Subject: [PATCH] Problem: WSS broken under contention Solution: Make wss_engine_t's read and write consistent with stream_engine_base_t --- src/wss_engine.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/wss_engine.cpp b/src/wss_engine.cpp index 986a6a4f..fc729d2a 100644 --- a/src/wss_engine.cpp +++ b/src/wss_engine.cpp @@ -194,6 +194,11 @@ int zmq::wss_engine_t::read (void *data_, size_t size_) return -1; } + if (rc == 0) { + errno = EPIPE; + return -1; + } + if (rc < 0) { errno = EINVAL; return -1; @@ -207,14 +212,8 @@ int zmq::wss_engine_t::write (const void *data_, size_t size_) { ssize_t rc = gnutls_record_send (_tls_session, data_, size_); - if (rc == GNUTLS_E_INTERRUPTED) { - errno = EINTR; - return -1; - } - - if (rc == GNUTLS_E_AGAIN) { - errno = EAGAIN; - return -1; + if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) { + return 0; } if (rc < 0) {