Skip to content
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

uv_tcp_close_reset() needs to handle some additional errno other than EINVAL on NetBSD #4409

Open
shored opened this issue May 17, 2024 · 2 comments

Comments

@shored
Copy link

shored commented May 17, 2024

Version: 1.48.0
Platform: NetBSD 9.2

https://github.com/libuv/libuv/blob/v1.48.0/src/unix/tcp.c#L399-L408

uv_tcp_close_reset() sets SO_LINGER then call uv_close().
If errno set in setsockopt() is EINVAL, it is converted to 0 then uv_close() is called.

While the man page tells different from the implementation, setsockopt() on NetBSD can return the other errno's which is better to be ignored in some situations (ECONNRESET, etc). It is not the case in other operating systems.

A caller of uv_tcp_close_reset() needs to check the return value and call uv_close() by hand if it encounters such errno's. As EINVAL (the socket has been shut down already) is handled explicitly, it would be better to also handle ECONNRESET (the socket has been reset by the remote) or such soft-failures gracefully.

Though it is a NetBSD-specific issue, a pkgsrc maintainer suggested to report this to the upstream.
https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=58234

@santigimeno
Copy link
Member

I would be ok adding those additional checks for NetBSD only. We should know the list of possible errors first though.

@saghul
Copy link
Member

saghul commented May 17, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants