IDLE MUST RUN!!!

Added idle counter to 1s timer.
Added rtos_delay_milliseconds in 1s timer, inside OTA, and in http tcp server and client threads.
Reason: During OTA, it could get to a state where the IDLE thread got no time.
The problem with this is that the tcp_client thread stack never got released, and so during this time, the heap was reduced by 8k for each call, resulting in no more heap, and death (hang).
This commit is contained in:
btsimonh
2022-10-25 12:31:24 +01:00
parent 8b7ba20544
commit dc00837cbc
3 changed files with 26 additions and 3 deletions

View File

@ -72,6 +72,7 @@ static void tcp_client_thread(beken_thread_arg_t arg)
//char reply[8192];
//my_fd = fd;
rtos_delay_milliseconds(20);
reply = (char*)os_malloc(replyBufferSize);
buf = (char*)os_malloc(INCOMING_BUFFER_SIZE);
@ -112,7 +113,7 @@ static void tcp_client_thread(beken_thread_arg_t arg)
send(fd, reply, lenret, 0);
}
rtos_delay_milliseconds(10);
//rtos_delay_milliseconds(10);
exit:
if (err != kNoErr)
@ -177,6 +178,12 @@ static void tcp_server_thread(beken_thread_arg_t arg)
// right now, I am getting OS_ThreadCreate everytime on XR809 platform
tcp_client_thread((beken_thread_arg_t)client_fd);
#else
// delay each accept by 20ms
// this allows previous to finish if
// in a loop of sends from the browser, e.g. OTA
// and we MUST get some IDLE thread time, else
// thread resources are not deleted.
rtos_delay_milliseconds(20);
// Create separate thread for client
if (kNoErr !=
#if PLATFORM_XR809