Skip to content

Commit e908bc6

Browse files
Merge branch 'thunks' of https://github.com/earlephilhower/Arduino into thunks
2 parents 40d17b5 + c34779b commit e908bc6

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ WiFiClientSecure::~WiFiClientSecure() {
129129
WiFiClientSecure::WiFiClientSecure(ClientContext* client,
130130
const BearSSLX509List *chain, const BearSSLPrivateKey *sk,
131131
int iobuf_in_size, int iobuf_out_size, const BearSSLX509List *client_CA_ta) {
132+
_cipher_list = NULL;
133+
_cipher_cnt = 0;
132134
_clear();
133135
_clearAuthenticationSettings();
134136
_iobuf_in_size = iobuf_in_size;
@@ -146,6 +148,8 @@ WiFiClientSecure::WiFiClientSecure(ClientContext *client,
146148
const BearSSLX509List *chain,
147149
unsigned cert_issuer_key_type, const BearSSLPrivateKey *sk,
148150
int iobuf_in_size, int iobuf_out_size, const BearSSLX509List *client_CA_ta) {
151+
_cipher_list = NULL;
152+
_cipher_cnt = 0;
149153
_clear();
150154
_clearAuthenticationSettings();
151155
_iobuf_in_size = iobuf_in_size;

libraries/ESP8266WiFi/src/include/ClientContext.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -308,39 +308,40 @@ class ClientContext
308308
if (!_pcb)
309309
return true;
310310

311-
int loop = -1;
312311
int prevsndbuf = -1;
313-
max_wait_ms++;
314312

315313
// wait for peer's acks to flush lwIP's output buffer
316-
314+
uint32_t last_sent = millis();
317315
while (1) {
316+
if (millis() - last_sent > (uint32_t) max_wait_ms) {
317+
#ifdef DEBUGV
318+
// wait until sent: timeout
319+
DEBUGV(":wustmo\n");
320+
#endif
321+
// All data was not flushed, timeout hit
322+
return false;
323+
}
318324

319325
// force lwIP to send what can be sent
320326
tcp_output(_pcb);
321327

322328
int sndbuf = tcp_sndbuf(_pcb);
323329
if (sndbuf != prevsndbuf) {
324330
// send buffer has changed (or first iteration)
325-
// we received an ack: restart the loop counter
326331
prevsndbuf = sndbuf;
327-
loop = max_wait_ms;
332+
// We just sent a bit, move timeout forward
333+
last_sent = millis();
328334
}
329335

330-
delay(1);
331-
if (state() != ESTABLISHED || sndbuf == TCP_SND_BUF || --loop <= 0)
332-
break;
333-
334-
}
336+
yield();
335337

336-
#ifdef DEBUGV
337-
if (loop <= 0) {
338-
// wait until sent: timeout
339-
DEBUGV(":wustmo\n");
338+
if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) {
339+
break;
340+
}
340341
}
341-
#endif
342342

343-
return max_wait_ms > 0;
343+
// All data flushed
344+
return true;
344345
}
345346

346347
uint8_t state() const
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Do not edit -- Automatically generated by tools/sdk/ssl/bearssl/Makefile
2-
#define BEARSSL_GIT f759cf8
2+
#define BEARSSL_GIT 7605337

0 commit comments

Comments
 (0)