Skip to content

Make an abort stop at once instead of downloading the remaining links - #2234

Merged
xroche merged 2 commits into
masterfrom
fix-436-abort-timing
Nov 14, 2026
Merged

xroche merged 2 commits into
masterfrom
fix-436-abort-timing

Conversation

@xroche

@xroche xroche commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

An abort used to download or probe every remaining link on the page before it stopped, because the waits for a link's type ignored it. The engine now stops at once and leaves those links online, and --continue fetches them. A soft stop (the first ^C, or hts_request_stop(opt, 0)) is unchanged. Only hard stops (the abort lock, SIGTERM, hts_request_stop(opt, 1)) leave the remaining links for --continue.

Test 436 failed on a macOS runner on #2231, because it passed only when the last file happened to be cut. It now checks that at most the first two files exist after the abort, and that --continue completes the mirror. Test 262 covers SIGTERM during the -%N0 type probe.

xroche and others added 2 commits November 14, 2026 14:40
An abort read from hts-abort.lock (or a SIGTERM) sets exit_xh, but the
parser's per-link type wait and the socket wait it starts with never
looked at it. With -c1 each link then waited for the previous transfer,
so the abort landed only after the whole page was downloaded.

Test 436 passed only because the last file was usually cut a few KB in;
on a macOS runner it had no body yet, so no ref was kept (seen on #2231).
Both waits now give up on an exit, the link is left online as with -E,
and test 436 checks that the last file is never fetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The -%N0 type probe in url_savename() checked only _hts_cancel and the
-E budget, so after SIGTERM the parse still probed the remaining links
one by one and then fetched them (13s on the new /slowhead/ fixture,
0.1s now). Test 262 covers it.

Test 436 now asserts that only p0 and p1 can exist after the abort, at
most one of them complete, with no temporary file left, and that a
--continue finishes all eight files with local links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche xroche changed the title Stop an abort without first fetching every link on the page Make an abort stop at once instead of downloading the remaining links Nov 14, 2026
@xroche
xroche enabled auto-merge (squash) November 14, 2026 14:37
@xroche
xroche merged commit b705807 into master Nov 14, 2026
41 checks passed
@xroche
xroche deleted the fix-436-abort-timing branch November 14, 2026 14:49
xroche added a commit that referenced this pull request Nov 14, 2026
An abort lock written during the `-%N0` link-type probe now stops the
crawl at once. Before, the crawl first probed every remaining link,
which took 14s in test 436. This is the lock-file half of #2234, which
fixed the same wait for SIGTERM. I also tried a poll in the slot wait
(`hts_wait_available_socket`) and dropped it, because no crawl I could
build needed it.

---------

Signed-off-by: Xavier Roche <roche@httrack.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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