ref: move user_consent to sentry_run_t for thread-safe access#1648
Open
ref: move user_consent to sentry_run_t for thread-safe access#1648
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 27343d4. Configure here.
27343d4 to
300ce44
Compare
Move require_user_consent and user_consent from sentry_options_t to
sentry_run_t as atomic longs. Add two helpers on sentry_run_t:
* sentry__run_should_skip_upload() — lock-free consent check the
batcher (and future workers) can call directly through their
refcounted run pointer, replacing the fragile raw long* into
options.
* sentry__run_load_user_consent() — loads the persisted consent file
(`<database>/user-consent`) into the run using an atomic store, so
callers outside the options lock (e.g. future crash-time consent
refreshes) can update it safely while worker threads read it.
Pure refactor: only existing call sites (batcher) are updated. No new
consent checks or daemon changes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
300ce44 to
002209b
Compare
mujacica
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Extracted from #1542.
Moves
require_user_consentanduser_consentfromsentry_options_ttosentry_run_tas atomic longs, and adds two helpers:sentry__run_should_skip_upload()— lock-free consent check callable from any thread via the refcounted run pointer, replacing the rawlong*-into-options pattern.sentry__run_load_user_consent()— loads<database>/user-consentinto the run via atomic store, so callers outside the options lock can refresh consent while worker threads read it.The batcher is updated to use the new helper; no other call sites are introduced yet.
Why
Unblocks #1542 and #1649, which need consent reads from worker threads and consent refreshes from contexts without the global options (e.g. the native crash daemon).
Scope
Pure refactor — no behavioral changes. No new consent checks, no daemon changes,
sentry__capture_envelopesignature unchanged.#skip-changelog (internal refactor)