Closing a socket.

Chris Johns chrisj at rtems.org
Wed May 11 21:51:13 UTC 2005


Thomas Rauscher wrote:
> 
> Maybe there is a race condition (visual check against 4.6.2).
> Please correct me if I'm wrong.

Yes there is a problem here.

> 
> If rtems_bsdnet_close is called, the socket is freed in
> soclose (depends on socket state, protocol used, ...).
> The waiting thread might wake up later (depends on
> scheduling) and could access so->so_pgid in soconnsleep().
> Bad things would happen if this memory area is now 
> used for something else...
> I remember having seen this in an accept/close race
> (rtems 4.5).

It looks to me like a bug in accept which I am looking at.

> 
> A clean (and portable) way is to send a 
> "QUIT" message to the socket so that the blocking
> thread can stop using the socket.
> 

What do you mean by a "QUIT" message ? Is this a way to have soconnwake 
and friends called ? If so a standard close on a socket fd does this.

> TCP connections can be closed with shutdown().

Is this a TCP socket shutdown or an RTEMS shutdown ?

-- 
  Chris Johns



More information about the users mailing list