in gloo/transport/tcp/tls/pair.cc [124:194]
bool Pair::read() {
NonOwningPtr<UnboundBuffer> buf;
for (;;) {
struct iovec iov = {
.iov_base = nullptr,
.iov_len = 0,
};
const auto nbytes = prepareRead(rx_, buf, iov);
if (nbytes < 0) {
return false;
}
// Break from loop if the op is complete.
// Note that this means that the buffer pointer has been
// set, per the call to prepareRead.
if (nbytes == 0) {
break;
}
ssize_t rv = 0;
for (;;) {
rv = _glootls::SSL_read(ssl_, iov.iov_base, iov.iov_len);
if (rv <= 0) {
int err = _glootls::SSL_get_error(ssl_, rv);
GLOO_ENFORCE(err != SSL_ERROR_NONE);
GLOO_ENFORCE(err != SSL_ERROR_WANT_WRITE);
if (err == SSL_ERROR_WANT_READ) {
return false;
}
if (err == SSL_ERROR_ZERO_RETURN) {
if (!sync_) {
return false;
}
}
if (err == SSL_ERROR_SYSCALL) {
fatal_error_occurred_ = true;
if (errno == EPIPE || errno == ECONNRESET) {
if (!sync_) {
return false;
}
}
}
// Unexpected error
signalException(GLOO_ERROR_MSG(
"SSL_read ", peer_.str(), " failed: ", "ssl error: ", err,
", errno = ", strerror(errno),
", ssl error message: ", getSSLErrorMessage()));
return false;
}
break;
}
// Transition to CLOSED on EOF
if (rv == 0) {
signalException(
GLOO_ERROR_MSG("Connection closed by peer ", peer_.str()));
return false;
}
rx_.nread += rv;
}
readComplete(buf);
return true;
}