[En-Nut-Discussion] killing threads waiting for a connection in NutTcpAccept

Harald Kipp harald.kipp at egnite.de
Thu Apr 9 10:36:51 CEST 2009


José Vallet wrote:
> Harald Kipp wrote:
>> José Vallet wrote:
>>
>>> I guess that for now we will have to live with a dirty solution to 
>>> unblock NutTcpAccept.
>> It may also work to close the stream and/or socket handle from another
>> thread, if these handles are globally available.
> 
> Actually closing the socket is what we tried first, but unfortunately it 
> didn't work. When the socket is closed NutTcpAccept continues blocking 
> the thread.
> 
> The stream is created right after NutTcpAccept, so we cannot close it 
> before.

José,

You're right, my hasty answer was blindfold.

In fact the socket is in TCPS_LISTEN state. When closing this socket, it
is simply destroyed, leaving the listening thread in a blocked state.
I'd consider this a bug.

NutTcpAbortSocket(sock, ECONNRESET);

should help here. Although its description states, that it should not be
called by application code, it is cleaner than using the internals of
the TCPSOCKET structure.

Harald




More information about the En-Nut-Discussion mailing list