1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-10-18 09:50:40 +03:00

Fix stopAllExcept with WiFiClientSecure (#8136)

Fixes #8079

Because WiFiClientSecure inherits WiFiClient, and WiFiClientSecureCtx also
inherits WiFiClient, they both end up in the list of TCP connections that
are used for WiFiClient::stopAllExcept().  This would cause the underlying
SSL connection to be closed whenever you attempted to
stopAllExcept(WiFiClientSecure)

Fix by adding a "_owned"(by) pointer in the WiFiClient object which points to
nullptr (default case) or to the associated lower-layer connection.
When stopping all connections except one, only look at the lowermost
connections.
This commit is contained in:
Earle F. Philhower, III
2021-06-20 10:43:05 -07:00
committed by GitHub
parent 2f37c967e1
commit 45e7976c50
3 changed files with 18 additions and 6 deletions

View File

@@ -232,8 +232,8 @@ class WiFiClientSecure : public WiFiClient {
public:
WiFiClientSecure():_ctx(new WiFiClientSecureCtx()) { }
WiFiClientSecure(const WiFiClientSecure &rhs): WiFiClient(), _ctx(rhs._ctx) { }
WiFiClientSecure():_ctx(new WiFiClientSecureCtx()) { _owned = _ctx.get(); }
WiFiClientSecure(const WiFiClientSecure &rhs): WiFiClient(), _ctx(rhs._ctx) { if (_ctx) _owned = _ctx.get(); }
~WiFiClientSecure() override { _ctx = nullptr; }
WiFiClientSecure& operator=(const WiFiClientSecure&) = default; // The shared-ptrs handle themselves automatically