Skip to content

Commit 572dff1

Browse files
igrrbryceschober
authored andcommitted
WiFiClient: clean up ClientContext before connecting (esp8266#4516)
Fixes esp8266#4497 (cherry picked from commit 95b1348)
1 parent 0a9c39c commit 572dff1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libraries/ESP8266WiFi/src/WiFiClient.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
112112
ip_addr_t addr;
113113
addr.addr = ip;
114114

115-
if (_client)
115+
if (_client) {
116116
stop();
117+
_client->unref();
118+
_client = nullptr;
119+
}
117120

118121
// if the default interface is down, tcp_connect exits early without
119122
// ever calling tcp_err

0 commit comments

Comments
 (0)