[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Thread safety of socket API

From: Sam Kearney
Subject: [lwip-users] Thread safety of socket API
Date: Wed, 11 Apr 2018 22:49:54 +0000

Hi all,

I have a question about the thread-safety of the socket API, specifically with 
regard to recvfrom() and close(). I am using lwIP 2.0.2, ported for FreeRTOS 
and ARM Cortex M4.

I have a thread that reads from a set of UDP sockets using select() and then 
calls recvfrom() on any ready sockets. I had assumed that it would be a safe 
operation to close() one of the sockets from a different thread context without 
worrying about what my receive thread is doing currently, and that if a 
recvfrom() was being called on that socket at the same time, it would simply 
exit with an error.

However, I seem to have triggered an assert failure from within 
netconn_recv_data(). I have a call stack that shows that close() was being 
called from a different thread at the time the assert failure happened.

I can provide more information if necessary, but first I need to verify my 
assumption about thread safety. Do I need to make sure that I'm not calling any 
other socket API functions on the same socket at the same time as I call 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]