mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-07 16:17:38 +03:00
Improve upload stability and throughput
- Reset watchdog BEFORE handleClient loop (fixes 1% crash) - Increase iterations from 200 to 500 - Reset watchdog every 32 iterations - Yield only every 64 iterations (reduces context switch overhead)
This commit is contained in:
parent
4767be7c01
commit
2328377ebf
@ -305,9 +305,7 @@ void CrossPointWebServerActivity::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle web server requests using time-based processing
|
// Handle web server requests - maximize throughput with watchdog safety
|
||||||
// Process requests for up to TIME_BUDGET_MS to maximize throughput
|
|
||||||
// while still allowing other loop activities to run
|
|
||||||
if (webServer && webServer->isRunning()) {
|
if (webServer && webServer->isRunning()) {
|
||||||
const unsigned long timeSinceLastHandleClient = millis() - lastHandleClientTime;
|
const unsigned long timeSinceLastHandleClient = millis() - lastHandleClientTime;
|
||||||
|
|
||||||
@ -317,18 +315,22 @@ void CrossPointWebServerActivity::loop() {
|
|||||||
timeSinceLastHandleClient);
|
timeSinceLastHandleClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process HTTP requests with watchdog safety
|
// Reset watchdog BEFORE processing - HTTP header parsing can be slow
|
||||||
// Use iteration-based approach with watchdog resets to prevent crashes
|
esp_task_wdt_reset();
|
||||||
// Higher iteration count improves throughput during uploads
|
|
||||||
constexpr int MAX_ITERATIONS = 200;
|
// Process HTTP requests in tight loop for maximum throughput
|
||||||
|
// More iterations = more data processed per main loop cycle
|
||||||
|
constexpr int MAX_ITERATIONS = 500;
|
||||||
for (int i = 0; i < MAX_ITERATIONS && webServer->isRunning(); i++) {
|
for (int i = 0; i < MAX_ITERATIONS && webServer->isRunning(); i++) {
|
||||||
webServer->handleClient();
|
webServer->handleClient();
|
||||||
// Yield every iteration to let WiFi stack receive more packets
|
// Reset watchdog every 32 iterations, yield every 64
|
||||||
yield();
|
// Tight loop with minimal yielding for maximum speed
|
||||||
// Reset watchdog every 50 iterations to prevent timeout during uploads
|
if ((i & 0x1F) == 0x1F) {
|
||||||
if ((i & 0x3F) == 0) { // Every 64 iterations
|
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
|
if ((i & 0x3F) == 0x3F) {
|
||||||
|
yield();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastHandleClientTime = millis();
|
lastHandleClientTime = millis();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user