Closing a socket.

Chris Johns chrisj at rtems.org
Thu May 12 03:20:47 UTC 2005


Till Straumann wrote:
>
> I agree. It's not OK to close a socket another thread is blocked on.

I think having a close unblock the thread and return an error code is 
the best solution.

> Besides so->so_pgid, the surrounding/calling syscall (accept, ...)
> also accesses the already released socket struct.

Yes. I am looking at this.

> 
> OTOH, deleting a blocked thread doesn't seem like a good solution either
> 

This is a definite no no. Unless the networking lock is move to the TCB 
and support added (which would be complex), it is not a good idea to 
delete a thread making networking calls.

The rule I use is any thread that makes networking calls deletes itself.

> --> I believe the rtems syscalls should be changed to make it safe to
> close a socket on which another thread is blocking. This could be achieved
> e.g., by letting soconnsleep/soconnwakeup use different events if the
> socket is being closed and propagating  an error code that prevents
> the socket structure being from accessed from the RTEMS glue code
> in this case.

... or block the close until the blocked thread has returned. I have 
something which appears to be working for accept, and I am now looking 
at the other calls.

Using another event, say SOCLOSED is a good idea. I may look at this. 
Thanks for the idea.

-- 
  Chris Johns



More information about the users mailing list