Commit a0c975df authored by dyarkovoy's avatar dyarkovoy Committed by Me No Dev

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.
parent 0906bf58
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment