fixed a bug with stopping SSLClient in the middle of a connection
This commit is contained in:
parent
02a8c5ff7c
commit
808bc15a1e
2 changed files with 7 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
name=SSLClient
|
name=SSLClient
|
||||||
version=1.2.0
|
version=1.2.1
|
||||||
author=Noah Koontz <koontzn@oregonstate.edu>
|
author=Noah Koontz <koontzn@oregonstate.edu>
|
||||||
maintainer=OPEnS Lab
|
maintainer=OPEnS Lab
|
||||||
sentence=Arduino library to add SSL functionality to any Client class
|
sentence=Arduino library to add SSL functionality to any Client class
|
||||||
|
|
|
@ -248,10 +248,12 @@ void SSLClientImpl::stop_impl() {
|
||||||
// tell the SSL connection to gracefully close
|
// tell the SSL connection to gracefully close
|
||||||
br_ssl_engine_close(&m_sslctx.eng);
|
br_ssl_engine_close(&m_sslctx.eng);
|
||||||
// if the engine isn't closed, and the socket is still open
|
// if the engine isn't closed, and the socket is still open
|
||||||
|
const auto state = br_ssl_engine_current_state(&m_sslctx.eng);
|
||||||
while (getWriteError() == SSL_OK
|
while (getWriteError() == SSL_OK
|
||||||
&& m_is_connected
|
&& m_is_connected
|
||||||
&& br_ssl_engine_current_state(&m_sslctx.eng) != BR_SSL_CLOSED
|
&& state != BR_SSL_CLOSED
|
||||||
&& m_run_until(BR_SSL_RECVAPP) == 0) {
|
&& state != 0
|
||||||
|
&& m_run_until(BR_SSL_SENDAPP | BR_SSL_RECVAPP) == 0) {
|
||||||
/*
|
/*
|
||||||
* Discard any incoming application data.
|
* Discard any incoming application data.
|
||||||
*/
|
*/
|
||||||
|
@ -263,12 +265,6 @@ void SSLClientImpl::stop_impl() {
|
||||||
}
|
}
|
||||||
// close the ethernet socket
|
// close the ethernet socket
|
||||||
get_arduino_client().flush();
|
get_arduino_client().flush();
|
||||||
// clear the intake buffer, if any
|
|
||||||
const auto avail = get_arduino_client().available();
|
|
||||||
if (avail > 0) {
|
|
||||||
m_info("Flushing bytes from client: ", func_name);
|
|
||||||
get_arduino_client().read(NULL, avail);
|
|
||||||
}
|
|
||||||
get_arduino_client().stop();
|
get_arduino_client().stop();
|
||||||
// we are no longer connected
|
// we are no longer connected
|
||||||
m_is_connected = false;
|
m_is_connected = false;
|
||||||
|
@ -414,7 +410,7 @@ int SSLClientImpl::m_run_until(const unsigned target) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// debug
|
// debug
|
||||||
if (state != lastState) {
|
if (state != lastState || lastState == 0) {
|
||||||
lastState = state;
|
lastState = state;
|
||||||
m_info("m_run changed state:", func_name);
|
m_info("m_run changed state:", func_name);
|
||||||
if(m_debug == DebugLevel::SSL_INFO) {
|
if(m_debug == DebugLevel::SSL_INFO) {
|
||||||
|
@ -440,7 +436,7 @@ int SSLClientImpl::m_run_until(const unsigned target) {
|
||||||
/*
|
/*
|
||||||
* If we reached our target, then we are finished.
|
* If we reached our target, then we are finished.
|
||||||
*/
|
*/
|
||||||
if (state & target) return 0;
|
if (state & target || (target == 0 && state == 0)) return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If some application data must be read, and we did not
|
* If some application data must be read, and we did not
|
||||||
|
|
Loading…
Reference in a new issue