mirror of
https://github.com/apache/nuttx.git
synced 2026-09-22 06:04:28 +08:00
TCP: check for connection before deleting it
It is possible for a socket to have no connection, for example if a TCP socket is waiting in accept. This checks for this condition in case the socket is closed from a different thread.
This commit is contained in:
committed by
Gregory Nutt
parent
f1ef2c6cde
commit
4875c6bbe3
@@ -524,9 +524,12 @@ int psock_close(FAR struct socket *psock)
|
||||
/* We perform the uIP close operation only if this is the last count on
|
||||
* the socket. (actually, I think the socket crefs only takes the values
|
||||
* 0 and 1 right now).
|
||||
*
|
||||
* It is possible for a psock to have no connection, e.g. a TCP socket
|
||||
* waiting in accept.
|
||||
*/
|
||||
|
||||
if (psock->s_crefs <= 1)
|
||||
if (psock->s_crefs <= 1 && psock->s_conn != NULL)
|
||||
{
|
||||
/* Perform uIP side of the close depending on the protocol type */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user