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

credential-cache: handle ECONNREFUSED gracefully #5329

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rimrul
Copy link
Member

@rimrul rimrul commented Dec 22, 2024

I should probably add some tests for this.

@rimrul rimrul force-pushed the credential-cache-unknown-error branch 2 times, most recently from ff41d09 to 1059d6f Compare December 22, 2024 18:47
Copy link

@hickford hickford Dec 23, 2024

Choose a reason for hiding this comment

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

To distinguish the two identical error messages "unable to connect to cache daemon", consider changing the second to “unable to connect to spawned cache daemon”

@rimrul rimrul force-pushed the credential-cache-unknown-error branch 3 times, most recently from 87d0f06 to a1ba9f8 Compare December 28, 2024 12:22
We map WSAGetLastError() errors to errno errors in winsock_error_to_errno(),
but the MSVC strerror() implementation only produces "Unknown error" for
most of them. Produce some more meaningful error messages in these
cases.

Our builds for ARM64 link against the newer UCRT strerror() that does know
these errors, so we won't change the strerror() used there.

The wording of the messages is copied from glibc strerror() messages.

Reported-by: M Hickford <[email protected]>
Signed-off-by: Matthias Aßhauer <[email protected]>
The part about keeping the original error number hasn't been accurate since
commit c11f75c (mingw: make sure errno is set correctly when socket
operations fail, 2019-11-25) and the part about strerror() not knowing
about these errors is untrue since the previous commit.

Signed-off-by: Matthias Aßhauer <[email protected]>
@rimrul rimrul force-pushed the credential-cache-unknown-error branch from a1ba9f8 to de3a367 Compare December 29, 2024 09:30
Commit 2406bf5 (Win32: detect unix socket support at runtime,
2024-04-03) introduced a runtime detection for wether the operating
system supports unix sockets for Windows, but a mistake snuck into the
tests. When building and testing Git without NO_UNIX_SOCKETS we
currently skip t0301-credential-cache on Windows if unix sockets are
supported and run the tests if they aren't.

Flip that logic to actually work the way it was intended.

Signed-off-by: Matthias Aßhauer <[email protected]>
In 245670c (credential-cache: check for windows specific errors, 2021-09-14)
we concluded that on Windows we would always encounter ENETDOWN where we
would expect ECONNREFUSED on POSIX systems, when connecting to unix sockets.
As reported in [1], we do encounter ECONNREFUSED on Windows if the
socket file doesn't exist, but the containing directory does and ENETDOWN if
neither exists. We should handle this case like we do on non-windows systems.

[1] git-for-windows#4762 (comment)

This fixes git-for-windows#5314

Helped-by: M Hickford <[email protected]>
Signed-off-by: Matthias Aßhauer <[email protected]>
@rimrul rimrul force-pushed the credential-cache-unknown-error branch from de3a367 to 42da5df Compare December 29, 2024 11:08
@rimrul rimrul marked this pull request as ready for review December 29, 2024 11:10
@rimrul
Copy link
Member Author

rimrul commented Dec 29, 2024

Turns out, the existing tests would've caught this issue, if I hadn't unintentionally sabotaged them

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

Successfully merging this pull request may close these issues.

credential-cache error "fatal: unable to connect to cache daemon: Unknown error"
2 participants