AnsweredAssumed Answered

Crash after  Websocket close

Question asked by Adrian Rockall on Jul 22, 2016
Latest reply on Aug 22, 2016 by Adrian Rockall

Hi,

 

I am using KSDK 1.3 with MQX and building with IAR for a MK66 processor.

 

I have found that my system crashed at a fault interrupt some time after closing a websocket. The crash was caused by the lwSemaphore code that searches for a semaphore that is being removed. Further investigation showed that there was a corrupted semaphore in the linked list and eventually I found that the session structure was being deleted without destroying the semaphore.

It appears that the httpsrv_ses_free function is called but not the httpsrv_ses_close when the websocket is closed.

 

I have added to httpsrv_ses_free in httpsrv_task.c:

    if (session)
    {
  //Adrian Rockall:- make sure the semaphore is destroyed before freeing the memory it sits in
        _lwsem_destroy(&session->lock);

        if (session->request.path)
        {
            _mem_free(session->request.path);
        }

 

That appears to solve the problem but I'm wondering the error is further up the chain with a missing call to httpsrv_ses_close?

 

I hope this helps anyone suffering the same problem but if anyone has a better solution I would be grateful.

 

Best regards,

Adrian.

Outcomes