Skip to content

Commit 0fba5b0

Browse files
BearSSLClient: stop issue
making _sslio_closing not static anymore, so that we are able to stop bearsslclients independently from one another
1 parent d4a65ea commit 0fba5b0

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/tls/BearSSLClient.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434

3535
#include "BearSSLClient.h"
3636

37-
bool BearSSLClient::_sslio_closing = false;
38-
3937
BearSSLClient::BearSSLClient() :
4038
_noSNI(false),
41-
_get_time_func(nullptr)
39+
_get_time_func(nullptr),
40+
_sslio_closing(false)
4241
{
4342
_ecKey.curve = 0;
4443
_ecKey.x = NULL;
@@ -169,7 +168,7 @@ void BearSSLClient::stop()
169168
{
170169
if (_client->connected()) {
171170
if ((br_ssl_engine_current_state(&_sc.eng) & BR_SSL_CLOSED) == 0) {
172-
BearSSLClient::_sslio_closing = true;
171+
_sslio_closing = true;
173172
br_sslio_close(&_ioc);
174173
}
175174

@@ -311,7 +310,7 @@ int BearSSLClient::connectSSL(const char* host)
311310
br_x509_minimal_set_time(&_xc, days, sec);
312311

313312
// use our own socket I/O operations
314-
br_sslio_init(&_ioc, &_sc.eng, BearSSLClient::clientRead, _client, BearSSLClient::clientWrite, _client);
313+
br_sslio_init(&_ioc, &_sc.eng, BearSSLClient::clientRead, this, BearSSLClient::clientWrite, this);
315314

316315
br_sslio_flush(&_ioc);
317316

@@ -332,12 +331,13 @@ int BearSSLClient::connectSSL(const char* host)
332331

333332
int BearSSLClient::clientRead(void *ctx, unsigned char *buf, size_t len)
334333
{
335-
if (BearSSLClient::_sslio_closing) {
334+
BearSSLClient* bc = (BearSSLClient*)ctx;
335+
Client* c = bc->_client;
336+
337+
if(bc->_sslio_closing) {
336338
return -1;
337339
}
338340

339-
Client* c = (Client*)ctx;
340-
341341
if (!c->connected()) {
342342
return -1;
343343
}
@@ -367,12 +367,13 @@ int BearSSLClient::clientRead(void *ctx, unsigned char *buf, size_t len)
367367

368368
int BearSSLClient::clientWrite(void *ctx, const unsigned char *buf, size_t len)
369369
{
370-
if (BearSSLClient::_sslio_closing) {
370+
BearSSLClient* bc = (BearSSLClient*)ctx;
371+
Client* c = bc->_client;
372+
373+
if(bc->_sslio_closing) {
371374
return -1;
372375
}
373376

374-
Client* c = (Client*)ctx;
375-
376377
#ifdef DEBUGSERIAL
377378
DEBUGSERIAL.print("BearSSLClient::clientWrite - ");
378379
DEBUGSERIAL.print(len);

src/tls/BearSSLClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class BearSSLClient : public Client {
100100
br_x509_certificate _ecCert;
101101
bool _ecCertDynamic;
102102

103-
static bool _sslio_closing;
103+
bool _sslio_closing;
104104
br_ssl_client_context _sc;
105105
br_x509_minimal_context _xc;
106106
unsigned char _ibuf[BEAR_SSL_CLIENT_IBUF_SIZE];

0 commit comments

Comments
 (0)