Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/EthernetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,18 @@ void EthernetClient::flush()

void EthernetClient::stop()
{
if (_tcp_client == NULL) {
return;
}

// close tcp connection if not closed yet
if (status() != TCP_CLOSING) {
tcp_connection_close(_tcp_client->pcb, _tcp_client);
if (_tcp_client != NULL) {
// close tcp connection if not closed yet
if (status() != TCP_CLOSING) {
if (_tcp_client->pcb == NULL) {
_tcp_client->state = TCP_CLOSING;
} else {
tcp_connection_close(_tcp_client->pcb, _tcp_client);
}
}
mem_free(_tcp_client);
_tcp_client = NULL;
}
mem_free(_tcp_client);
_tcp_client = NULL;
}

uint8_t EthernetClient::connected()
Expand Down
2 changes: 1 addition & 1 deletion src/lwipopts_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ a lot of data that needs to be copied, this should be set high. */
#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS)

/* TCP receive window. */
#define TCP_WND (3*TCP_MSS)
#define TCP_WND (4*TCP_MSS)

#define LWIP_TCP_KEEPALIVE 1 /* Keep the TCP link active. Important for MQTT/TLS */
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 /* Prevent the same port to be used after reset.
Expand Down
4 changes: 3 additions & 1 deletion src/utility/stm32_eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,9 @@ void tcp_connection_close(struct tcp_pcb *tpcb, struct tcp_struct *tcp)
tcp_accept(tpcb, NULL);

/* close tcp connection */
tcp_close(tpcb);
if (tcp_close(tpcb) != ERR_OK) {
tcp_abort(tpcb);
}

tcp->pcb = NULL;
tcp->state = TCP_CLOSING;
Expand Down