mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-17 13:29:05 +03:00
coap_openssl.c: Clear thread errors before doing read/write for TLS
When using multi-threads, if a thread does i/o, but previously that thread had an SSL error which has not been properly cleared, then the read or write will fail with SSL_ERROR_SSL. Make sure that there are no errors before doing SSL_read() or SSL_write().
This commit is contained in:
1 parent
205f52fe24
commit
440b645a15
1 file changed
+2
@@ -3932,6 +3932,7 @@ coap_tls_write(coap_session_t *session, const uint8_t *data, size_t data_len) {
|
||||
|
||||
in_init = !SSL_is_init_finished(ssl);
|
||||
session->dtls_event = -1;
|
||||
ERR_clear_error();
|
||||
r = SSL_write(ssl, data, (int)data_len);
|
||||
|
||||
if (r <= 0) {
|
||||
@@ -4011,6 +4012,7 @@ coap_tls_read(coap_session_t *session, uint8_t *data, size_t data_len) {
|
||||
|
||||
in_init = !SSL_is_init_finished(ssl);
|
||||
session->dtls_event = -1;
|
||||
ERR_clear_error();
|
||||
r = SSL_read(ssl, data, (int)data_len);
|
||||
if (r <= 0) {
|
||||
int err = SSL_get_error(ssl, r);
|
||||
|
||||
Reference in new issue
Block a user