From 2dfed2fea15bdfca48dc7fe6a87ee7b3e5692032 Mon Sep 17 00:00:00 2001 From: Victor Aprea Date: Wed, 10 Apr 2019 21:16:26 -0400 Subject: [PATCH] add opportunity for more than one retry to _uploadReadByte --- libraries/WebServer/src/Parsing.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/WebServer/src/Parsing.cpp b/libraries/WebServer/src/Parsing.cpp index e55e6873c8f..ad49a68061d 100644 --- a/libraries/WebServer/src/Parsing.cpp +++ b/libraries/WebServer/src/Parsing.cpp @@ -304,10 +304,27 @@ void WebServer::_uploadWriteByte(uint8_t b){ int WebServer::_uploadReadByte(WiFiClient& client){ int res = client.read(); - if(res == -1){ - while(!client.available() && client.connected()) + const uint8_t max_retries = 3; + uint8_t numRetries = 0; + while(numRetries < max_retries && res == -1){ + while(!client.available() && client.connected()){ delay(2); + } + res = client.read(); + // NOTE: it is possible to get here and have all of the following + // assertions hold true + // + // -- client.available() > 0 + // -- client.connected == true + // -- res == -1 + // + // a simple retry strategy overcomes this which is to say the + // assertion is not permanent, but the reason that this works + // is ellusive, and possibly indicative of a more subtle underlying + // issue + + numRetries++; } return res; }