In sock_close.c/closesocket(), if a streaming socket is abruptly closed, there is an instance where _task_start_preemption() is not called, but it should be. This means that preemption for the calling thread is disabled until a call to _task_start_preemption() occurs.
int32_t closesocket(uint32_t sock)
{
...
else
if(((uint32_t)socket_ptr->PROTOCOL) == SOCK_STREAM)
{
struct tcb_parm parms;
if(NULL == socket_ptr->TCB_PTR)
{
_task_start_preemption(); //***Add this call here ***
goto exit;
}
...
}
...
}