-
Notifications
You must be signed in to change notification settings - Fork 13.3k
(properly) check whether ClientContext::connect()'s delay is interrupted by disconnected WiFi #4197
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
Conversation
May I suggest doing |
Upon reading the (existing) code once again, i have a question regarding LwIP. With lwip 1.4, when WiFi connection was terminated, error callbacks set on PCBs using Now, with lwip2, it seems that the order is different: error callbacks set on PCBs are not being called before the WiFi event callbacks. Could this be changed, instead of introducing this additional logic? |
I remember having considered ref/unref in the first sleepless-PR I made, and I don't remember why I discarded the idea. You are right, this is the proper solution. |
I revisited again this bug without fix. I get the bad sequence with both lwip (when AP disappear during the second delay). Are you validating this ? |
With code
|
I think that the fact we do |
The problem is that we can be interrupted in yields (
In
... Or afterall, in
with no static variables |
I updated this PR with the "guarded_delay" proposal |
I think all interrupted cases are handled. |
Usually a check that |
@igrr I agree: use of delete this is generally a Bad Idea, and that is what is happening in this case. I think this is an example:
Therefore, if we want to do away with delete this, if(this), etc, I think we'd have to do away with the whole ref()/unref() model in clientcontext. The thing is, that would be a change that impacts pretty much all TCP-based apps, so I'd say it's a bit risky for a minor release. |
I agree with that, using std::shared_ptr is not much more expensive but is a lot nicer. We still need to have the reference counting implementation so that sketches can copy WiFiClient object and pass it by value, as it is sometimes done in Arduino (thanks to the Java/Processing roots of the syntax). Sorry, I got a bit overwhelmed by some other duties, but my solution, in a nutshell, to avoid deleting the ClientContext on This seems to work but I want to do a stress test for this, with one ESP connected to other ESP's SoftAp, some TCP traffic between the two, and AP randomly shutting down and starting up. |
replaced by #4389 |
No description provided.