FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #6 from abelsensors/feature/VV-3453_SocketWaitForData · abelsensors/esp32_https_server@2407227 · GitHub

Repository navigation

Commit 2407227

Browse files
authored
Merge pull request #6 from abelsensors/feature/VV-3453_SocketWaitForData
VV-3453 Increase socket data available timeout to 250ms
2 parents 95ce9c5 + b47ad6f commit 2407227

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎src/HTTPConnection.cpp‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ int HTTPConnection::updateBuffer() {
172172
}
173173
_bufferUnusedIdx -= _bufferProcessed;
174174
_bufferProcessed = 0;
175-
176175
}
177176

178177
if (_bufferUnusedIdx < HTTPS_CONNECTION_DATA_CHUNK_SIZE) {
@@ -198,7 +197,7 @@ int HTTPConnection::updateBuffer() {
198197
} else if (readReturnCode == 0) {
199198
// The connection has been closed by the client
200199
_clientState = CSTATE_CLOSED;
201-
HTTPS_LOGI("Client closed connection, FID=%d", _socket);
200+
HTTPS_LOGW("Client closed connection, FID=%d", _socket);
202201
// TODO: If we are in state websocket, we might need to do something here
203202
return 0;
204203
} else {
@@ -212,7 +211,7 @@ int HTTPConnection::updateBuffer() {
212211
// When the connection for whatever reason is unable to receive more data, the application essentially gets
213212
// stuck in an infinite while loop. This extra timeout check prevents this from occurring.
214213
} else if (isTimeoutExceeded()) {
215-
HTTPS_LOGI("Connection timeout. FID=%d", _socket);
214+
HTTPS_LOGW("Connection timeout. FID=%d", _socket);
216215
closeConnection();
217216
return -1;
218217
}
@@ -227,10 +226,10 @@ bool HTTPConnection::canReadData() {
227226
FD_ZERO( &sockfds );
228227
FD_SET(_socket, &sockfds);
229228

230-
// We define an immediate timeout (return immediately, if there's no data)
229+
// Wait up to 250 ms for data to be available before returning false
231230
timeval timeout;
232-
timeout.tv_sec = 0;
233-
timeout.tv_usec = 0;
231+
timeout.tv_sec = 0;
232+
timeout.tv_usec = 250000;
234233

235234
// Check for input
236235
// As by 2017-12-14, it seems that FD_SETSIZE is defined as 0x40, but socket IDs now

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL