[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Closing a socket.
> -----Original Message-----
> From: Chris Johns [mailto:email@example.com]
> Sent: Wednesday, May 11, 2005 2:34 AM
> To: RTEMS Users
> Subject: Closing a socket.
> Can a socket be closed by one thread while another thread is
> blocked in the socket (soconnsleep) ?
> If not does a way exist to wake the blocked thread or should
> the thread be deleted before closing the socket ?
Maybe there is a race condition (visual check against 4.6.2).
Please correct me if I'm wrong.
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
A clean (and portable) way is to send a
"QUIT" message to the socket so that the blocking
thread can stop using the socket.
TCP connections can be closed with shutdown().
LOYTEC electronics GmbH