Skip to content

backport: Merge bitcoin#26742, 28551#7357

Merged
PastaPastaPasta merged 2 commits into
dashpay:developfrom
vijaydasmp:June_2026_3
Jun 15, 2026
Merged

backport: Merge bitcoin#26742, 28551#7357
PastaPastaPasta merged 2 commits into
dashpay:developfrom
vijaydasmp:June_2026_3

Conversation

@vijaydasmp

Copy link
Copy Markdown

Bitcoin back ports

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

achow101 and others added 2 commits June 13, 2026 23:52
… finish - 2nd attempt

60978c8 test: Reduce extended timeout on abortnode test (Fabian Jahr)
660bdbf http: Release server before waiting for event base loop exit (João Barbosa)
8c6d007 http: Track active requests and wait for last to finish (João Barbosa)

Pull request description:

  This revives bitcoin#19420. Since promag is not so active at the moment, I can support this to finally get it merged.

  The PR is rebased and comments by jonatack have been addressed.

  Once this is merged, I will also reopen bitcoin#19434.

ACKs for top commit:
  achow101:
    ACK 60978c8
  stickies-v:
    re-ACK [60978c8](bitcoin@60978c8)
  hebasto:
    ACK 60978c8

Tree-SHA512: eef0fe1081e9331b95cfafc71d82f2398abd1d3439dac5b2fa5c6d9c0a3f63ef19adde1c38c88d3b4e7fb41ce7c097943f1815c10e33d165918ccbdec512fe1c
…emote client disconnection

68f23f5 http: bugfix: track closed connection (stickies-v)
084d037 http: log connection instead of request count (stickies-v)
41f9027 http: refactor: use encapsulated HTTPRequestTracker (stickies-v)

Pull request description:

  bitcoin#26742 significantly increased the http server shutdown speed, but also introduced a bug (bitcoin#27722 - see bitcoin#27722 (comment) for steps to reproduce on master) that causes http server shutdown to halt in case of a remote client disconnection. This happens because `evhttp_request_set_on_complete_cb` is never called and thus the request is never removed from `g_requests`.

  This PR fixes that bug, and improves robustness of the code by encapsulating the request tracking logic. Earlier approaches (bitcoin#27909, bitcoin#27245, bitcoin#19434) attempted to resolve this but [imo are fundamentally unsafe](bitcoin#27909 (comment)) because of differences in lifetime between an `evhttp_request` and `evhttp_connection`.

  We don't need to keep track of open requests or connections, we just [need to ensure](bitcoin#19420 (comment)) that there are no active requests on server shutdown. Because a connection can have multiple requests, and a request can be completed in various ways (the request actually being handled, or the client performing a remote disconnect), keeping a counter per connection seems like the approach with the least overhead to me.

  Fixes bitcoin#27722

ACKs for top commit:
  vasild:
    ACK 68f23f5
  theStack:
    ACK 68f23f5

Tree-SHA512: dfa711ff55ec75ba44d73e9e6fac16b0be25cf3c20868c2145a844a7878ad9fc6998d9ff62d72f3a210bfa411ef03d3757b73d68a7c22926e874c421e51444d6
@vijaydasmp vijaydasmp marked this pull request as ready for review June 15, 2026 08:33
@thepastaclaw

thepastaclaw commented Jun 15, 2026

Copy link
Copy Markdown

✅ Review complete (commit 4998a3f)

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0a7e4de7-ba54-4deb-a14e-9b67f273f73a

📥 Commits

Reviewing files that changed from the base of the PR and between 7fcc54a and 4998a3f.

📒 Files selected for processing (2)
  • src/httpserver.cpp
  • test/functional/feature_abortnode.py

Walkthrough

src/httpserver.cpp introduces a new HTTPRequestTracker class that maintains a mutex-guarded unordered_map from evhttp_connection* to in-flight request counts, with a condition variable for blocking until the map is empty. The http_request_cb callback is extended to call AddRequest on arrival and to install per-request completion and per-connection close callbacks that call RemoveRequest/RemoveConnection. StopHTTPServer() is reworked to call WaitUntilEmpty() after unlistening sockets, then schedules evhttp_free to execute on the event-base thread via event_base_once instead of calling it directly. In test/functional/feature_abortnode.py, the explicit rpc_timeout = 240 is removed and wait_until_stopped timeout is reduced from 200 to 5 seconds.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • PastaPastaPasta
  • thepastaclaw
  • knst
  • UdjinM6
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description 'Bitcoin back ports' is related to the changeset but is very generic and lacks meaningful detail about the actual changes being made. Expand the description to explain what improvements are being backported, such as HTTP server graceful shutdown handling and request tracking functionality.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the pull request as backporting two specific Bitcoin pull requests, which aligns with the changeset that adds HTTP request tracking and graceful shutdown handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw thepastaclaw 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.

Code Review

Clean backport of Bitcoin Core PRs bitcoin#26742 and bitcoin#28551. Both backport-reviewer specialists confirmed all prerequisites are merged. The merge resolution preserves Dash-specific code paths (external_usernames split work queue) without regression. The single nitpick from Claude is on verbatim upstream code and the reviewer themselves noted no action is required — dropped per backport review skill.

Comment thread src/httpserver.cpp Outdated
Comment on lines +22 to +26
#include <cstdio>
#include <deque>
#include <optional>
#include <string>
#include <unordered_set>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing include for condition_variable

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK 4998a3f

@PastaPastaPasta PastaPastaPasta merged commit 77cf281 into dashpay:develop Jun 15, 2026
48 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.

5 participants