Skip to content

better client handling of server connection timeouts#282

Merged
andylemin merged 1 commit into
mainfrom
client-timeout
Jul 7, 2026
Merged

better client handling of server connection timeouts#282
andylemin merged 1 commit into
mainfrom
client-timeout

Conversation

@rdmark

@rdmark rdmark commented Jul 4, 2026

Copy link
Copy Markdown
Member

this is made up of two distinct changes: introduce an explicit timeout for server connection and enables both afpcmd and kio-afp to report timeout errors accurately, and an overhaul to afpcmd connection attempt verbosity

Use a temporary nonblocking socket and select to limit server connection attempts to DSI_DEFAULT_TIMEOUT instead of allowing connect to block indefinitely.

Restore the original socket flags on every handled path, rebuild select state on EINTR retries, and preserve errno from failed connect, select, or getsockopt calls so callers retain the expected failure reason.

Report afp_sl_connect failures from the afpcmd startup path with the returned errno text while suppressing duplicate non-verbose log messages.

before, the kio-afp client would throw unknown errors, and the afpcmd client would throw nonsense like this for an unreachable server

dmark@daniel-macbookpro:~/dev/netatalk-client$ afpcmd afp://airport-time-capsule.local:548
airport-time-capsule.local resolved only to link-local addresses; trying airport-time-capsule
Login error: Authentication failed
Could not connect to server: Permission denied
dmark@daniel-macbookpro:~/dev/netatalk-client$ afpcmd afp://dmark@airport-time-capsule.local:548
Password:
airport-time-capsule.local resolved only to link-local addresses; trying airport-time-capsule
Could not connect, never got a response to getstatus, Connection timed out
Could not connect to server: Connection timed out

after the fix we get

dmark@daniel-macbookpro:~/dev/netatalk-client$ afpcmd afp://airport-time-capsule.local:548
Could not connect to server: Connection timed out
dmark@daniel-macbookpro:~/dev/netatalk-client$ afpcmd afp://dmark@airport-time-capsule.local:548
Password:
Could not connect to server: Connection timed out

@rdmark rdmark requested a review from andylemin as a code owner July 4, 2026 21:09
@augmentcode

augmentcode Bot commented Jul 4, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR adds an explicit timeout for initial server TCP connections and improves how clients report connection timeouts.

Changes:

  • Introduces connect_with_timeout() (non-blocking connect + select()) and uses it in afp_server_connect() to bound connect time.
  • Updates afpcmd to suppress duplicate log lines and to print connection failures as Could not connect to server: <strerror>.
  • Downgrades some connection-failure log messages in afp_server_full_connect() from LOG_ERR to LOG_INFO to avoid misleading output at default verbosity.

Technical Notes: The TCP connect timeout currently uses DSI_DEFAULT_TIMEOUT (5s) for the connect step.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread lib/afp.c
Comment thread lib/afp.c Outdated
Use a temporary nonblocking socket and select to limit server connection
attempts to DSI_DEFAULT_TIMEOUT instead of allowing connect to block
indefinitely.

Restore the original socket flags on every handled path, rebuild select
state on EINTR retries, and preserve errno from failed connect, select,
or getsockopt calls so callers retain the expected failure reason.

Report afp_sl_connect failures from the afpcmd startup path with the
returned errno text while suppressing duplicate non-verbose log messages.
@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

@andylemin andylemin merged commit b5192af into main Jul 7, 2026
31 of 32 checks passed
@rdmark rdmark deleted the client-timeout branch July 7, 2026 20:39
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.

2 participants