Skip to content

ref: move user_consent to sentry_run_t for thread-safe access#1648

Open
jpnurmi wants to merge 1 commit intomasterfrom
jpnurmi/ref/run-consent
Open

ref: move user_consent to sentry_run_t for thread-safe access#1648
jpnurmi wants to merge 1 commit intomasterfrom
jpnurmi/ref/run-consent

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Apr 15, 2026

Extracted from #1542.

Moves require_user_consent and user_consent from sentry_options_t to sentry_run_t as 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 raw long*-into-options pattern.
  • sentry__run_load_user_consent() — loads <database>/user-consent into 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_envelope signature unchanged.

#skip-changelog (internal refactor)

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread src/sentry_core.c Outdated
Comment thread src/sentry_database.c
@jpnurmi jpnurmi force-pushed the jpnurmi/ref/run-consent branch from 27343d4 to 300ce44 Compare April 15, 2026 07:45
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>
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.

2 participants