Closing a socket.

Thomas Rauscher trauscher at loytec.com
Thu May 12 07:32:20 UTC 2005


  

> -----Original Message-----
> From: Chris Johns [mailto:chrisj at rtems.org] 
> Sent: Wednesday, May 11, 2005 11:51 PM
> To: Thomas Rauscher
> Cc: rtems-users at rtems.com
> Subject: Re: Closing a socket.
> 
> 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.
> 

No, I meant to create a sending socket and sending a message to
the listening thread using a special QUIT, EXIT, CLOSE or whatever
packet. Of course this only an option in self-designed protocols.

> > TCP connections can be closed with shutdown().
> 
> Is this a TCP socket shutdown or an RTEMS shutdown ?
> 

I was thinking about the BSD socket shutdown() function. 
Sorry for being imprecise.

Regards,
Thomas Rauscher


--
Thomas Rauscher
LOYTEC electronics GmbH
Stolzenthalergasse 24/3
A-1080 Wien
Austria/Europe
trauscher at loytec.com
www.loytec.com
Phone: +43-1-4020805-15
FAX:   +43-1-4020805-99

Networks under control!
LOYTEC and NEC Electronics Join Forces in Building Automation!
 

> -- 
>   Chris Johns
> 
> 



More information about the users mailing list