Skip to content

make DSI default timeout dynamically configurable#204

Open
rdmark wants to merge 1 commit intomainfrom
rdmark-timeout-configurable
Open

make DSI default timeout dynamically configurable#204
rdmark wants to merge 1 commit intomainfrom
rdmark-timeout-configurable

Conversation

@rdmark
Copy link
Copy Markdown
Member

@rdmark rdmark commented Apr 18, 2026

Add a dsi_default_timeout field to struct afp_server, initialized to DSI_DEFAULT_TIMEOUT (5s) and overridden per server type after identify: Time Capsule servers get DSI_TIMECAPSULE_DEFAULT_TIMEOUT (30s) to accommodate spinning disk wake-up latency.

Both AFP clients now accept a -t/--timeout option to let the user override the timeout at launch, taking precedence over the server-type default. The value is threaded through the IPC request structs (afp_server_mount_request, afp_server_connect_request) and applied to the server object after connection. All protocol call sites that previously used the DSI_DEFAULT_TIMEOUT compile-time constant now read server->dsi_default_timeout instead.

Add a dsi_default_timeout field to struct afp_server, initialized to
DSI_DEFAULT_TIMEOUT (5s) and overridden per server type after identify:
Time Capsule servers get DSI_TIMECAPSULE_DEFAULT_TIMEOUT (30s) to
accommodate spinning disk wake-up latency.

Both AFP clients now accept a -t/--timeout <seconds> option to let the
user override the timeout at launch, taking precedence over the
server-type default. The value is threaded through the IPC request
structs (afp_server_mount_request, afp_server_connect_request) and
applied to the server object after connection. All protocol call sites
that previously used the DSI_DEFAULT_TIMEOUT compile-time constant now
read server->dsi_default_timeout instead.
@sonarqubecloud
Copy link
Copy Markdown

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 18, 2026

🤖 Augment PR Summary

Summary: This PR makes the DSI request timeout configurable at runtime instead of being a fixed compile-time constant.

Changes:

  • Adds dsi_default_timeout to struct afp_server, initialized to 5s (DSI_DEFAULT_TIMEOUT)
  • Updates Time Capsule detection to switch the default to 30s after identification (DSI_TIMECAPSULE_DEFAULT_TIMEOUT)
  • Adds -t/--timeout <seconds> to both AFP clients to let users override the timeout
  • Threads the override through the IPC request structs (afp_server_*_request) and applies it to the connected server object
  • Replaces protocol call sites that used DSI_DEFAULT_TIMEOUT to instead read server->dsi_default_timeout
  • Updates manpages for afp_client and afpcmd to document the new option and defaults

Technical Notes: The per-server default is selected based on server type (Time Capsule vs others), and user overrides take precedence when a positive timeout value is provided.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 4 suggestions posted.

Fix All in Augment

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

Comment thread include/afp.h
unsigned int tx_delay;

/* DSI request timeout in seconds; set by server type detection or user override */
int dsi_default_timeout;
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 18, 2026

Choose a reason for hiding this comment

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

Adding dsi_default_timeout to the public struct afp_server changes the struct layout/size, which is an ABI break for any external consumers that access this struct from libafpclient (not just source-level API changes). Can you confirm the project intends this ABI change (e.g., via SONAME bump / documented ABI versioning)?

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread lib/identify.c
s->server_name_printable);
s->server_type = AFPFS_SERVER_TYPE_TIMECAPSULE;

if (s->dsi_default_timeout == DSI_DEFAULT_TIMEOUT) {
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 18, 2026

Choose a reason for hiding this comment

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

Using s->dsi_default_timeout == DSI_DEFAULT_TIMEOUT as the “not user overridden” sentinel can’t distinguish between the default 5s and an explicit user choice of 5s, so an explicit 5s set before afp_server_identify() could still be overridden to 30s for Time Capsule.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread fuse/client.c
break;

case 't':
request.dsi_timeout = strtol(optarg, NULL, 10);
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 18, 2026

Choose a reason for hiding this comment

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

--timeout is parsed via strtol(optarg, NULL, 10) without checking endptr/errno/range, so invalid or overflow inputs can silently turn into 0/garbage and be ignored or misapplied. This is user-facing and can make it hard to tell whether the override was accepted.

Severity: low

Other Locations
  • cmdline/cmdline_main.c:516

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread cmdline/cmdline_main.c
{"recursive", 0, 0, 'r'},
{"verbose", 0, 0, 'V'},
{"loglevel", 1, 0, 'v'},
{"timeout", 1, 0, 't'},
Copy link
Copy Markdown

@augmentcode augmentcode bot Apr 18, 2026

Choose a reason for hiding this comment

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

usage() output here still doesn’t mention the new -t/--timeout option, so -h help is now incomplete compared to the manpage and the actual supported flags.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

1 participant