Skip to content

Commit efc8dda

Browse files
committed
Workaround for LwIP not handling ERR_ABRT
Described in detail here: https://github.com/esp8266/Arduino/wiki/LwIP-issue,-or-how-a-simple-%22if%22-can-go-wrong
1 parent 5e19757 commit efc8dda

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libraries/ESP8266WiFi/src/include/ClientContext.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ClientContext {
3535
_pcb(pcb), _rx_buf(0), _rx_buf_offset(0), _discard_cb(discard_cb), _discard_cb_arg(discard_cb_arg), _refcnt(0), _next(0), _send_waiting(false) {
3636
tcp_setprio(pcb, TCP_PRIO_MIN);
3737
tcp_arg(pcb, this);
38-
tcp_recv(pcb, &_s_recv);
38+
tcp_recv(pcb, (tcp_recv_fn) &_s_recv);
3939
tcp_sent(pcb, &_s_sent);
4040
tcp_err(pcb, &_s_error);
4141
}
@@ -269,12 +269,13 @@ class ClientContext {
269269
}
270270
}
271271

272-
err_t _recv(tcp_pcb* pcb, pbuf* pb, err_t err) {
272+
int32_t _recv(tcp_pcb* pcb, pbuf* pb, err_t err) {
273273

274274
if(pb == 0) // connection closed
275275
{
276-
DEBUGV(":rcla\r\n");
277-
return abort();
276+
DEBUGV(":rcl\r\n");
277+
abort();
278+
return ERR_ABRT;
278279
}
279280

280281
if(_rx_buf) {
@@ -306,7 +307,7 @@ class ClientContext {
306307
return ERR_OK;
307308
}
308309

309-
static err_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, err_t err) {
310+
static int32_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, err_t err) {
310311
return reinterpret_cast<ClientContext*>(arg)->_recv(tpcb, pb, err);
311312
}
312313

0 commit comments

Comments
 (0)