-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetworkClient - close the connection in stop() method #9542
Conversation
👋 Hello JAndrassy, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
aaf6cae
to
54dcb55
Compare
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
for all copies referring it
54dcb55
to
9a9e719
Compare
Thanks for PR @JAndrassy, we will review it soon. |
@JAndrassy can you come up with a test case for this? Think of a sketch that would use multiple copies of the client and close when it should. The sketch should not require external libs |
the best example is an attempt to implement server.available() and print-to-all-clients in 'external library'.
|
Status update:
|
the sketch above is an almost real world example. of course for a CI test a much simpler example would work |
a simple test:
|
Hello @JAndrassy, can you please provide full small example which fails without your changes and work afterwards? |
|
Did you test the sketch you posted? We are still getting same result with/without PR changes. |
tested and retested now. the difference is, that without the PR it prints "still connected" |
My bad, I have my environment for testing set wrongly. Its fine now |
this PR allows to close the TCP connection in
client.stop()
for all copies of NetworkClient which wrap the same TCP connection.The existence of multiple copies of WiFiClient for the same TCP connection is a feature of the 'Arduino language' and the networking libraries must deal with it.
Destroy of a NetworkClient instance should not close the TCP connection unless it is the last copy handling that connection. Thanks to shared_ptr NetworkClientSocketHandle instance closes the connection as it is destroyed when the last copy of NetworkClient for that connection is destroyed.
tested with WiFiPagerServer example from my NetAPIHelpers library with this added: