Re: TCP socket handling errors

From: Sad Clouds <cryintothebluesky_at_gmail.com>
Date: Wed, 03 Apr 2024 17:46:38 UTC
On Wed, 3 Apr 2024 17:28:52 +0200
Michael Tuexen <michael.tuexen@lurchi.franken.de> wrote:

> > On 3. Apr 2024, at 15:44, Sad Clouds <cryintothebluesky@gmail.com> wrote:
> > 
> > I found a bug that is still open from May 2010 and describes the same
> > behaviour that I see with my application:
> > 
> > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=146845
> > 
> > If this hasn't been fixed over the last 14 years, then I guess I will
> > add some code to simply ignore ECONNRESET on close(2) for FreeBSD and
> > MacOS. This seems the be the general advice from other people who hit
> > this issue.
> I'll bring this up on the bi-weekly FreeBSD transport call.
> 
> Best regards
> Michael
> > 
> 

Hello, I've attached a test program, this easily reproduces the issue
on Raspberry Pi 4 within a few seconds of running it.

Server output:
$ ./econnreset server
Server: accept()
Server: shutdown()
Server: close()
...
Server: accept()
Server: shutdown()
Server: close()
close() failed, error=Connection reset by peer


Client output (aborts when server exists due to close() failure):
$ while true; do ./econnreset client || break; done
Client: connect()
Client: shutdown()
Client: close()
...
Client: connect()
Assertion failed: (int_val == 0), function client, file econnreset.c,
line 156. Abort trap (core dumped)