TLSInStream* self= (TLSInStream*) str;
InStream *in = self->in;
+ delete self->saved_exception;
+ self->saved_exception = NULL;
+
try {
if (!in->hasData(1)) {
gnutls_transport_set_errno(self->session, EAGAIN);
} catch (SystemException &e) {
vlog.error("Failure reading TLS data: %s", e.str());
gnutls_transport_set_errno(self->session, e.err);
+ self->saved_exception = new SystemException(e);
return -1;
} catch (Exception& e) {
vlog.error("Failure reading TLS data: %s", e.str());
gnutls_transport_set_errno(self->session, EINVAL);
+ self->saved_exception = new Exception(e);
return -1;
}
}
TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
- : session(_session), in(_in)
+ : session(_session), in(_in), saved_exception(NULL)
{
gnutls_transport_ptr_t recv, send;
TLSInStream::~TLSInStream()
{
gnutls_transport_set_pull_function(session, NULL);
+
+ delete saved_exception;
}
bool TLSInStream::fillBuffer(size_t maxSize)
if (n == GNUTLS_E_INTERRUPTED || n == GNUTLS_E_AGAIN)
return 0;
- if (n < 0) throw TLSException("readTLS", n);
+ if (n == GNUTLS_E_PULL_ERROR)
+ throw *saved_exception;
+
+ if (n < 0)
+ throw TLSException("readTLS", n);
if (n == 0)
throw EndOfStream();
gnutls_session_t session;
InStream* in;
+
+ Exception* saved_exception;
};
};
TLSOutStream* self= (TLSOutStream*) str;
OutStream *out = self->out;
+ delete self->saved_exception;
+ self->saved_exception = NULL;
+
try {
out->writeBytes(data, size);
out->flush();
} catch (SystemException &e) {
vlog.error("Failure sending TLS data: %s", e.str());
gnutls_transport_set_errno(self->session, e.err);
+ self->saved_exception = new SystemException(e);
return -1;
} catch (Exception& e) {
vlog.error("Failure sending TLS data: %s", e.str());
gnutls_transport_set_errno(self->session, EINVAL);
+ self->saved_exception = new Exception(e);
return -1;
}
}
TLSOutStream::TLSOutStream(OutStream* _out, gnutls_session_t _session)
- : session(_session), out(_out), bufSize(DEFAULT_BUF_SIZE), offset(0)
+ : session(_session), out(_out), bufSize(DEFAULT_BUF_SIZE), offset(0),
+ saved_exception(NULL)
{
gnutls_transport_ptr_t recv, send;
gnutls_transport_set_push_function(session, NULL);
delete [] start;
+ delete saved_exception;
}
size_t TLSOutStream::length()
if (n == GNUTLS_E_INTERRUPTED || n == GNUTLS_E_AGAIN)
return 0;
+ if (n == GNUTLS_E_PUSH_ERROR)
+ throw *saved_exception;
+
if (n < 0)
throw TLSException("writeTLS", n);
size_t bufSize;
U8* start;
size_t offset;
+
+ Exception* saved_exception;
};
};