File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -396,11 +396,8 @@ impl Hub {
396396 F : FnOnce ( & mut Scope ) -> R ,
397397 {
398398 with_client_impl ! { {
399- let ( new_scope, rv) = self . with_current_scope( |scope| {
400- let mut new_scope = ( * * scope) . clone( ) ;
401- let rv = f( & mut new_scope) ;
402- ( new_scope, rv)
403- } ) ;
399+ let mut new_scope = self . with_current_scope( |scope| scope. clone( ) ) ;
400+ let rv = f( & mut new_scope) ;
404401 self . with_current_scope_mut( |ptr| * ptr = new_scope) ;
405402 rv
406403 } }
@@ -440,7 +437,7 @@ impl Hub {
440437 }
441438
442439 #[ cfg( feature = "client" ) ]
443- pub ( crate ) fn with_current_scope < F : FnOnce ( & Arc < Scope > ) -> R , R > ( & self , f : F ) -> R {
440+ pub ( crate ) fn with_current_scope < F : FnOnce ( & Scope ) -> R , R > ( & self , f : F ) -> R {
444441 self . inner . with ( |stack| f ( & stack. top ( ) . scope ) )
445442 }
446443
Original file line number Diff line number Diff line change @@ -120,3 +120,22 @@ fn test_factory() {
120120
121121 assert_eq ! ( events. load( Ordering :: SeqCst ) , 1 ) ;
122122}
123+
124+ #[ test]
125+ fn test_reentrant_configure_scope ( ) {
126+ let events = sentry:: test:: with_captured_events ( || {
127+ sentry:: configure_scope ( |scope1| {
128+ scope1. set_tag ( "which_scope" , "scope1" ) ;
129+
130+ sentry:: configure_scope ( |scope2| {
131+ scope2. set_tag ( "which_scope" , "scope2" ) ;
132+ } ) ;
133+ } ) ;
134+
135+ sentry:: capture_message ( "look ma, no deadlock!" , sentry:: Level :: Info ) ;
136+ } ) ;
137+
138+ assert_eq ! ( events. len( ) , 1 ) ;
139+ // well, the "outer" `configure_scope` wins
140+ assert_eq ! ( events[ 0 ] . tags[ "which_scope" ] , "scope1" ) ;
141+ }
You can’t perform that action at this time.
0 commit comments