return IOState::NeedWrite;
}
else if (error == SSL_ERROR_SYSCALL) {
- throw std::runtime_error("Error while processing TLS connection:" + std::string(strerror(errno)));
+ throw std::runtime_error("Error while processing TLS connection: " + std::string(strerror(errno)));
}
else {
- throw std::runtime_error("Error while processing TLS connection:" + std::to_string(error));
+ throw std::runtime_error("Error while processing TLS connection: " + std::to_string(error));
}
}
auto state = convertIORequestToIOState(res);
if (state == IOState::NeedRead) {
res = waitForData(d_socket, timeout);
- if (res <= 0) {
- throw std::runtime_error("Error reading from TLS connection");
+ if (res == 0) {
+ throw std::runtime_error("Timeout while reading from TLS connection");
+ }
+ else if (res < 0) {
+ throw std::runtime_error("Error waiting to read from TLS connection");
}
}
else if (state == IOState::NeedWrite) {
res = waitForRWData(d_socket, false, timeout, 0);
- if (res <= 0) {
+ if (res == 0) {
+ throw std::runtime_error("Timeout while writing to TLS connection");
+ }
+ else if (res < 0) {
throw std::runtime_error("Error waiting to write to TLS connection");
}
}
{
do {
int res = SSL_write(d_conn.get(), reinterpret_cast<const char *>(&buffer.at(pos)), static_cast<int>(toWrite - pos));
- if (res == 0) {
- throw std::runtime_error("Error writing to TLS connection");
- }
- else if (res < 0) {
+ if (res <= 0) {
return convertIORequestToIOState(res);
}
else {
{
do {
int res = SSL_read(d_conn.get(), reinterpret_cast<char *>(&buffer.at(pos)), static_cast<int>(toRead - pos));
- if (res == 0) {
- throw std::runtime_error("Error reading from TLS connection");
- }
- else if (res < 0) {
+ if (res <= 0) {
return convertIORequestToIOState(res);
}
else {
do {
int res = SSL_read(d_conn.get(), (reinterpret_cast<char *>(buffer) + got), static_cast<int>(bufferSize - got));
- if (res == 0) {
- throw std::runtime_error("Error reading from TLS connection");
- }
- else if (res < 0) {
+ if (res <= 0) {
handleIORequest(res, readTimeout);
}
else {
size_t got = 0;
do {
int res = SSL_write(d_conn.get(), (reinterpret_cast<const char *>(buffer) + got), static_cast<int>(bufferSize - got));
- if (res == 0) {
- throw std::runtime_error("Error writing to TLS connection");
- }
- else if (res < 0) {
+ if (res <= 0) {
handleIORequest(res, writeTimeout);
}
else {
}
else if (res < 0) {
if (gnutls_error_is_fatal(res)) {
- throw std::runtime_error("Error writing to TLS connection");
+ throw std::runtime_error("Fatal error writing to TLS connection: " + std::string(gnutls_strerror(res)));
}
else if (res == GNUTLS_E_AGAIN) {
return IOState::NeedWrite;
}
else if (res < 0) {
if (gnutls_error_is_fatal(res)) {
- throw std::runtime_error("Error reading from TLS connection");
+ throw std::runtime_error("Fatal error reading from TLS connection: " + std::string(gnutls_strerror(res)));
}
else if (res == GNUTLS_E_AGAIN) {
return IOState::NeedRead;
}
else if (res < 0) {
if (gnutls_error_is_fatal(res)) {
- throw std::runtime_error("Error reading from TLS connection:" + std::string(gnutls_strerror(res)));
+ throw std::runtime_error("Fatal error reading from TLS connection: " + std::string(gnutls_strerror(res)));
}
else if (res == GNUTLS_E_AGAIN) {
int result = waitForData(d_socket, readTimeout);
if (result <= 0) {
- throw std::runtime_error("Error reading from TLS connection: " + std::to_string(result));
+ throw std::runtime_error("Error while waiting to read from TLS connection: " + std::to_string(result));
}
}
else {
}
else if (res < 0) {
if (gnutls_error_is_fatal(res)) {
- throw std::runtime_error("Error writing to TLS connection: " + std::string(gnutls_strerror(res)));
+ throw std::runtime_error("Fatal error writing to TLS connection: " + std::string(gnutls_strerror(res)));
}
else if (res == GNUTLS_E_AGAIN) {
int result = waitForRWData(d_socket, false, writeTimeout, 0);