kern/146845: [libc] close(2) returns error 54 (connection reset by peer) wrongly

Mikolaj Golub to.my.trociny at gmail.com
Sun May 30 08:05:52 UTC 2010


On Fri, 28 May 2010 04:40:03 GMT Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:

 >  IMHO, it is not, unfortunately, a solution:  it seems to clear ECONNRESET
 >  blindly and w/o distinguishing the situation when the remote end closes the
 >  connection prematurely (i.e. before acknowledging all data written from the
 >  local end) -- and that qualifies for the true "connection reset by peer"
 >  from close()...

I did some experiments the results I would like to share here. The idea is
following: the client sends data in one write() more then a win, while the
server closes the connection without reading (sending RST on close). I also
played with LINGER option. I have managed to get ECONNRESET only on write(),
if the server sends RST before the client calls write(). In all other cases
write()/close() returned without error. See the attachment for details. 

So I think that with the workaround (ignore ECONNRESET returned by
sodisconnect() in soclose()) we would not make the situation worse (while it
fixed the issue with applications getting unexpectedly ECONNRESET after
shutdown()/close() sequence).

-- 
Mikolaj Golub

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_tcp_close.c
Type: application/octet-stream
Size: 11859 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20100530/4bd5d8fe/test_tcp_close.obj


More information about the freebsd-net mailing list