Skip to content

fix: Ignore remote peer aborts when accepting clients #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/FubarDev.FtpServer/MultiBindingTcpListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ private async Task<AcceptInfo> AcceptForListenerAsync(TcpListener listener, int
// Ignore the exception. This happens when the listener gets stopped.
return new AcceptInfo(null, index);
}
catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionReset)
Copy link
Preview

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Update the XML doc comment for AcceptForListenerAsync to explicitly note that a SocketError.ConnectionReset (10054) is intentionally ignored so consumers understand why certain connection resets don’t bubble up.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no XML doc on this method or on this line. Where would I put it? Add a new one on this private method, and then cascade to callers?

IMO, XML doc should match common practice of specifying which exceptions may be thrown, but the lib currently does not do that - does not include this even on exposed interfaces - AFAIK anway.

Copy link
Preview

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider merging this filter with the existing exception handling to reduce duplication, e.g., using a combined filter: catch (Exception ex) when (ex is ObjectDisposedException || (ex is SocketException se && se.SocketErrorCode == SocketError.ConnectionReset)).

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both blocks currently have different comments. Those would be hard to represent.

{
// The remote peer closed the connection during the handshake process. We ignore these.
return new AcceptInfo(null, index);
}
}

private int StartListening(IEnumerable<IPAddress> addresses, int port)
Expand Down