clear error queue before calling SSL_read()/SSL_write(), to avoid remaining errors to corrupt the next connection attempts and cause disconnections

This commit is contained in:
csoler 2016-06-26 23:14:01 -04:00
parent 31089d7a91
commit ff8667834b

View File

@ -1548,6 +1548,7 @@ int pqissl::senddata(void *data, int len)
#ifdef PQISSL_DEBUG
std::cout << "Sending data thread=" << pthread_self() << ", ssl=" << (void*)this << ", size=" << len << std::endl ;
#endif
ERR_clear_error();
tmppktlen = SSL_write(ssl_connection, data, len) ;
if (len != tmppktlen)
@ -1638,6 +1639,8 @@ int pqissl::readdata(void *data, int len)
#ifdef PQISSL_DEBUG
std::cerr << "calling SSL_read. len=" << len << ", total_len=" << total_len << std::endl ;
#endif
ERR_clear_error() ;
tmppktlen = SSL_read(ssl_connection, (void*)( &(((uint8_t*)data)[total_len])), len-total_len) ;
#ifdef PQISSL_DEBUG
std::cerr << "have read " << tmppktlen << " bytes" << std::endl ;