-
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
WiFiClient - assignment shouldn't stop connection #9029
WiFiClient - assignment shouldn't stop connection #9029
Conversation
there may be other copy of WiFiClient working with that connection. let shared_ptr stop the connection when it is not refered anymore.
👋 Hello JAndrassy, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Same here, thanks for the PR, awaiting review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In the current implementation, the call to arduino-esp32/libraries/WiFi/src/WiFiClient.cpp Lines 200 to 207 in cc6da05
Those are not copied from the other WiFiClient. (in the current situation)No idea if Client from which WiFiClient inherits has any members which need to be copied, but those are also not copied.
No idea yet whether that's important or not. In your PR you let the compiler generate this function , which essentially does the same as the I can't oversee yet whether this is a problem, but what I do see is that this change does not match your description of why you need this change as it still does reassign a clientSocketHandle and buffer. The only thing I can imagine is that maybe the So my question is what actual problem or use case do you try to fix here? |
the actual problem is a warning (which causes PR tests to end with error). the warning says that a copy constructor must exist if assignment operator is defined. but the assignment operator is only defined to stop the connection. and it shouldn't do that. so instead of adding a copy constructor we delete the assignment operator. |
Sounds like you're also testing using PVS Studio? :) Or is there a compiler flag which can also tell me this, then I would really like to know (and use) it. :) Anyway, about this PR, I don't know whether this actually may change behavior as it depends on the implementation of the shared_ptr and what these timeout values are used for. |
I use Eclipse Sloeber. |
I know, but like I said the only difference here is that the shared_ptr is assigned a So the only difference here is there will be an assignment of a nullptr inbetween. (current implementation) |
sorry. yes. I forgot that in esp8266 the connection closes from local side only if the last copy is destroyed. that is a way to prevent invalid copies. already two or three time in last years I wondered why a connection continuous to work when I invoked stop() |
@JAndrassy so what does this PR improve in reality? |
removes code which causes trouble and confusion. for example the WiFiServer PR #9028 fails checks because of existence of this assignment operator |
PR is failing, because you are compiling for H2, which does not have WiFi at all. But yes, this also gives warning. |
assignment shouldn't stop connection in the left client. there may be other copy of WiFiClient working with that connection.
let shared_ptr stop the connection when it is not referred anymore.
the default assignment operator works ok.