Skip to content

Deduplicate the wait-for-socket macros and the stats-refresh loop tick#484

Merged
xroche merged 2 commits into
masterfrom
wait-socket-dedup
Jul 4, 2026
Merged

Deduplicate the wait-for-socket macros and the stats-refresh loop tick#484
xroche merged 2 commits into
masterfrom
wait-socket-dedup

Conversation

@xroche

@xroche xroche commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Follow-up to #482, which had to patch the same -E checkmirror break into two byte-for-byte copies of the wait-for-socket macro (URLSAVENAME_WAIT_FOR_AVAILABLE_SOCKET in htsname.c, WAIT_FOR_AVAILABLE_SOCKET in htsparse.h). The first commit folds them into a single hts_wait_available_socket().

The core of the macro body, refreshing the transfer stats and running the loop callback, also existed open-coded at six more sites in htsname.c and htsparse.c, differing only in the slot index passed to the callback and the abort action. The second commit collapses them onto a shared hts_loop_tick(); each caller keeps its own abort path. No behavior change, net -100 lines, and make check stays green.

xroche and others added 2 commits July 4, 2026 14:51
URLSAVENAME_WAIT_FOR_AVAILABLE_SOCKET (htsname.c) and
WAIT_FOR_AVAILABLE_SOCKET (htsparse.h) were byte-for-byte duplicates,
both carrying the #481 checkmirror break. Replace them with a single
hts_wait_available_socket() in htscore.c; the callback-abort path still
returns -1 from the callers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The wait-for-socket macro body (stats refresh + loop callback) also
existed open-coded at six more sites across htsname.c and htsparse.c,
differing only in the slot index passed to the callback and the abort
action. Collapse all of them onto a shared hts_loop_tick(); each caller
keeps its own abort path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche xroche merged commit f0b044c into master Jul 4, 2026
15 checks passed
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