mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-27 21:16:50 +03:00
fix connection reset by peer case (#4626)
* fix connection reset by peer case where pcb is set to null in ClientContext::_error but not reported to WiFiClient * ClientContext: rename functions *_sent to *_acked (:sent to :ack in debug) * use nullptr instead of 0
This commit is contained in:
parent
4305275f8d
commit
b08d282673
@ -280,7 +280,7 @@ void WiFiClient::stop()
|
||||
|
||||
uint8_t WiFiClient::connected()
|
||||
{
|
||||
if (!_client)
|
||||
if (!_client || _client->state() == CLOSED)
|
||||
return 0;
|
||||
|
||||
return _client->state() == ESTABLISHED || available();
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
tcp_setprio(pcb, TCP_PRIO_MIN);
|
||||
tcp_arg(pcb, this);
|
||||
tcp_recv(pcb, &_s_recv);
|
||||
tcp_sent(pcb, &_s_sent);
|
||||
tcp_sent(pcb, &_s_acked);
|
||||
tcp_err(pcb, &_s_error);
|
||||
tcp_poll(pcb, &_s_poll, 1);
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
tcp_err(_pcb, NULL);
|
||||
tcp_poll(_pcb, NULL, 0);
|
||||
tcp_abort(_pcb);
|
||||
_pcb = 0;
|
||||
_pcb = nullptr;
|
||||
}
|
||||
return ERR_ABRT;
|
||||
}
|
||||
@ -79,7 +79,7 @@ public:
|
||||
tcp_abort(_pcb);
|
||||
err = ERR_ABRT;
|
||||
}
|
||||
_pcb = 0;
|
||||
_pcb = nullptr;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -471,11 +471,11 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
err_t _sent(tcp_pcb* pcb, uint16_t len)
|
||||
err_t _acked(tcp_pcb* pcb, uint16_t len)
|
||||
{
|
||||
(void) pcb;
|
||||
(void) len;
|
||||
DEBUGV(":sent %d\r\n", len);
|
||||
DEBUGV(":ack %d\r\n", len);
|
||||
_write_some_from_cb();
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -536,7 +536,7 @@ protected:
|
||||
tcp_sent(_pcb, NULL);
|
||||
tcp_recv(_pcb, NULL);
|
||||
tcp_err(_pcb, NULL);
|
||||
_pcb = NULL;
|
||||
_pcb = nullptr;
|
||||
_notify_error();
|
||||
}
|
||||
|
||||
@ -571,9 +571,9 @@ protected:
|
||||
return reinterpret_cast<ClientContext*>(arg)->_poll(tpcb);
|
||||
}
|
||||
|
||||
static err_t _s_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len)
|
||||
static err_t _s_acked(void *arg, struct tcp_pcb *tpcb, uint16_t len)
|
||||
{
|
||||
return reinterpret_cast<ClientContext*>(arg)->_sent(tpcb, len);
|
||||
return reinterpret_cast<ClientContext*>(arg)->_acked(tpcb, len);
|
||||
}
|
||||
|
||||
static err_t _s_connected(void* arg, struct tcp_pcb *pcb, err_t err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user