close() failing with ECONNRESET

Mikolaj Golub to.my.trociny at gmail.com
Wed Jun 9 10:43:16 UTC 2010


On Wed, 9 Jun 2010 12:45:52 +0300 Kostik Belousov wrote:

 KB> On Wed, Jun 09, 2010 at 12:35:11AM -0700, perryh at pluto.rain.com wrote:
 >> Timo Sirainen <tss at iki.fi> wrote:
 >> 
 >> > I see that since FreeBSD 6.3 close() can fail with:
 >> >
 >> > > [ECONNRESET]        The underlying object was a stream socket that was
 >> > >                 shut down by the peer before all pending data was
 >> > >                 delivered.
 >> >
 >> > Could someone explain what this is useful for?
 KB> Note that any return from close(2) that does not set errno to EBADF
 KB> closes the supplied file descriptor. Mentioned errno value supplies
 KB> caller with the information that not "all pending data was delivered".

We have kern/146845 about close(2) returning ECONNRESET for tcp
connections. Looking at the code (which I am not very familiar with though)
and running some tests make me think that currently ECONNRESET may be only
returned by close(2) after shutdown()/close() on our side and simultaneous
close() on the other side (and in this case this is wrong).

-- 
Mikolaj Golub


More information about the freebsd-hackers mailing list