diff --git a/src/backends/sentry_backend_crashpad.cpp b/src/backends/sentry_backend_crashpad.cpp index f629ebadb..06e028934 100644 --- a/src/backends/sentry_backend_crashpad.cpp +++ b/src/backends/sentry_backend_crashpad.cpp @@ -65,7 +65,8 @@ sentry__crashpad_backend_user_consent_changed(sentry_backend_t *backend) } static void -sentry__crashpad_backend_flush_scope(sentry_backend_t *backend) +sentry__crashpad_backend_flush_scope( + sentry_backend_t *backend, const sentry_options_t *options) { const crashpad_state_t *data = (crashpad_state_t *)backend->data; if (!data->event_path) { @@ -78,7 +79,7 @@ sentry__crashpad_backend_flush_scope(sentry_backend_t *backend) sentry_value_t event = sentry_value_new_object(); SENTRY_WITH_SCOPE (scope) { // we want the scope without any modules or breadcrumbs - sentry__scope_apply_to_event(scope, event, SENTRY_SCOPE_NONE); + sentry__scope_apply_to_event(scope, options, event, SENTRY_SCOPE_NONE); } size_t mpack_size; diff --git a/src/sentry_backend.h b/src/sentry_backend.h index 1eb025d38..02faf3303 100644 --- a/src/sentry_backend.h +++ b/src/sentry_backend.h @@ -11,24 +11,22 @@ * can ensure that any captured crash contains the sentry scope and other * information. */ -struct sentry_backend_s; -typedef struct sentry_backend_s { - int (*startup_func)( - struct sentry_backend_s *, const sentry_options_t *options); - void (*shutdown_func)(struct sentry_backend_s *); - void (*free_func)(struct sentry_backend_s *); - void (*except_func)( - struct sentry_backend_s *, const struct sentry_ucontext_s *); - void (*flush_scope_func)(struct sentry_backend_s *); +typedef struct sentry_backend_s sentry_backend_t; +struct sentry_backend_s { + int (*startup_func)(sentry_backend_t *, const sentry_options_t *options); + void (*shutdown_func)(sentry_backend_t *); + void (*free_func)(sentry_backend_t *); + void (*except_func)(sentry_backend_t *, const struct sentry_ucontext_s *); + void (*flush_scope_func)( + sentry_backend_t *, const sentry_options_t *options); // NOTE: The breadcrumb is not moved into the hook and does not need to be // `decref`-d internally. - void (*add_breadcrumb_func)( - struct sentry_backend_s *, sentry_value_t breadcrumb); - void (*user_consent_changed_func)(struct sentry_backend_s *); - uint64_t (*get_last_crash_func)(struct sentry_backend_s *); + void (*add_breadcrumb_func)(sentry_backend_t *, sentry_value_t breadcrumb); + void (*user_consent_changed_func)(sentry_backend_t *); + uint64_t (*get_last_crash_func)(sentry_backend_t *); void *data; bool can_capture_after_shutdown; -} sentry_backend_t; +}; /** * This will free a previously allocated backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index 43cf9ed74..704d8549c 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -376,7 +376,7 @@ sentry__prepare_event(const sentry_options_t *options, sentry_value_t event, if (!options->symbolize_stacktraces) { mode &= ~SENTRY_SCOPE_STACKTRACES; } - sentry__scope_apply_to_event(scope, event, mode); + sentry__scope_apply_to_event(scope, options, event, mode); } if (options->before_send_func) { diff --git a/src/sentry_core.h b/src/sentry_core.h index 156801ff1..46e546630 100644 --- a/src/sentry_core.h +++ b/src/sentry_core.h @@ -70,11 +70,6 @@ sentry_value_t sentry__ensure_event_id( */ const sentry_options_t *sentry__options_getref(void); -/** - * Release the lock on the global options. - */ -void sentry__options_unlock(void); - #define SENTRY_WITH_OPTIONS(Options) \ for (const sentry_options_t *Options = sentry__options_getref(); Options; \ sentry_options_free((sentry_options_t *)Options), Options = NULL) diff --git a/src/sentry_scope.c b/src/sentry_scope.c index 814b6f815..143049e77 100644 --- a/src/sentry_scope.c +++ b/src/sentry_scope.c @@ -127,7 +127,7 @@ sentry__scope_flush_unlock(const sentry_scope_t *scope) // we try to unlock the scope/session lock as soon as possible. The // backend will do its own `WITH_SCOPE` internally. if (options->backend && options->backend->flush_scope_func) { - options->backend->flush_scope_func(options->backend); + options->backend->flush_scope_func(options->backend, options); } } if (!did_unlock) { @@ -237,8 +237,9 @@ sentry__symbolize_stacktrace(sentry_value_t stacktrace) } void -sentry__scope_apply_to_event( - const sentry_scope_t *scope, sentry_value_t event, sentry_scope_mode_t mode) +sentry__scope_apply_to_event(const sentry_scope_t *scope, + const sentry_options_t *options, sentry_value_t event, + sentry_scope_mode_t mode) { #define IS_NULL(Key) sentry_value_is_null(sentry_value_get_by_key(event, Key)) #define SET(Key, Value) sentry_value_set_by_key(event, Key, Value) @@ -264,11 +265,9 @@ sentry__scope_apply_to_event( PLACE_STRING("platform", "native"); - SENTRY_WITH_OPTIONS (options) { - PLACE_STRING("release", options->release); - PLACE_STRING("dist", options->dist); - PLACE_STRING("environment", options->environment); - } + PLACE_STRING("release", options->release); + PLACE_STRING("dist", options->dist); + PLACE_STRING("environment", options->environment); if (IS_NULL("level")) { SET("level", sentry__value_new_level(scope->level)); diff --git a/src/sentry_scope.h b/src/sentry_scope.h index e22cc945d..a6bb6155e 100644 --- a/src/sentry_scope.h +++ b/src/sentry_scope.h @@ -67,7 +67,8 @@ void sentry__scope_flush_unlock(const sentry_scope_t *scope); * attached. */ void sentry__scope_apply_to_event(const sentry_scope_t *scope, - sentry_value_t event, sentry_scope_mode_t mode); + const sentry_options_t *options, sentry_value_t event, + sentry_scope_mode_t mode); /** * This will update a sessions `distinct_id`, which is generated out of other diff --git a/tests/unit/test_mpack.c b/tests/unit/test_mpack.c index d805108eb..391a3d892 100644 --- a/tests/unit/test_mpack.c +++ b/tests/unit/test_mpack.c @@ -17,13 +17,15 @@ SENTRY_TEST(mpack_removed_tags) sentry_set_extra("int", sentry_value_new_int32(1234)); sentry_set_extra("double", sentry_value_new_double(12.34)); + sentry_options_t *options = sentry_options_new(); SENTRY_WITH_SCOPE (scope) { - sentry__scope_apply_to_event(scope, obj, SENTRY_SCOPE_NONE); + sentry__scope_apply_to_event(scope, options, obj, SENTRY_SCOPE_NONE); } size_t size; char *buf = sentry_value_to_msgpack(obj, &size); + sentry_options_free(options); sentry_value_decref(obj); sentry_free(buf); sentry__scope_cleanup();