Reset retry counter upon successful write (#2638)

Currently  WiFiClient::write is unable to send messages over 25Kb, because of the hard-coded retry limit of 10, that is getting decremented on every successful send. Since we cannot send more than 2*MTU bytes in one go, and have only 10 retries, write() is limited to approximately 25Kb. Technically it is not a bug, as it correctly returns the number of sent bytes and the caller can set up futher retries. But not all libs are aware of this behavior, for example, WebServer is not.
I suggest improving current behavior by resetting retry counter every time we had a successful write, so the limit of 10 retries will apply to Failed writes only, and will not apply to Successful writes. This will allow to write() blobs of arbitrary sizes.
This commit is contained in:
dyarkovoy 2019-04-10 03:41:29 +03:00 committed by Me No Dev
parent 0906bf580f
commit a0c975dfbc

View File

@ -358,6 +358,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
} else {
buf += res;
bytesRemaining -= res;
retry = WIFI_CLIENT_MAX_WRITE_RETRY;
}
}
else if(res < 0) {