Skip to content
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

Timeout rollover problem #7

Open
cwalger opened this issue Apr 22, 2019 · 1 comment
Open

Timeout rollover problem #7

cwalger opened this issue Apr 22, 2019 · 1 comment

Comments

@cwalger
Copy link

cwalger commented Apr 22, 2019

This timeout math looks like it will not work properly during a millis() rollover.
I think first two lines here should be changed to the last two lines:

//int timeout_at = millis() + _timeout;
//while (!client.available() && timeout_at - millis() < 0) {
unsigned long start = millis();
while (!client.available() && millis() - start < _timeout) {	//millis() - start < ms
@teHwHoly
Copy link

Hi!
I'm really not sure, why the existing while loop shall be working..
replaced it with the following:

unsigned long start = millis();
while (!client.available()) {
	if (millis() - start > _timeout) {
		client.stop();
		return false;
	}
}

This way it stays in the while loop, waiting for the client and returns (cancels) the routine just if timeout occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants