@@ -300,17 +300,17 @@ impl Oidc {
300
300
/// olm machine has been initialized.
301
301
///
302
302
/// Must be called after `set_session_meta`.
303
- async fn deferred_enable_cross_process_refresh_lock ( & self ) -> Result < ( ) > {
303
+ async fn deferred_enable_cross_process_refresh_lock ( & self ) {
304
304
let deferred_init_lock = self . ctx ( ) . deferred_cross_process_lock_init . lock ( ) . await ;
305
305
306
306
// Don't `take()` the value, so that subsequent calls to
307
307
// `enable_cross_process_refresh_lock` will keep on failing if we've enabled the
308
308
// lock at least once.
309
309
let Some ( lock_value) = deferred_init_lock. as_ref ( ) else {
310
- return Ok ( ( ) ) ;
310
+ return ;
311
311
} ;
312
312
313
- // FIXME We shouldn't be using the crypto store for that! see also https://github.com/matrix-org/matrix-rust-sdk/issues/2472
313
+ // FIXME: We shouldn't be using the crypto store for that! see also https://github.com/matrix-org/matrix-rust-sdk/issues/2472
314
314
let olm_machine_lock = self . client . olm_machine ( ) . await ;
315
315
let olm_machine =
316
316
olm_machine_lock. as_ref ( ) . expect ( "there has to be an olm machine, hopefully?" ) ;
@@ -323,8 +323,6 @@ impl Oidc {
323
323
// This method is guarded with the `deferred_cross_process_lock_init` lock held,
324
324
// so this `set` can't be an error.
325
325
let _ = self . ctx ( ) . cross_process_token_refresh_manager . set ( manager) ;
326
-
327
- Ok ( ( ) )
328
326
}
329
327
330
328
/// The OpenID Connect authentication data.
@@ -708,7 +706,7 @@ impl Oidc {
708
706
} ;
709
707
710
708
self . client . set_session_meta ( meta) . await ?;
711
- self . deferred_enable_cross_process_refresh_lock ( ) . await ? ;
709
+ self . deferred_enable_cross_process_refresh_lock ( ) . await ;
712
710
713
711
self . client
714
712
. inner
@@ -913,14 +911,23 @@ impl Oidc {
913
911
// At this point the Olm machine has been set up.
914
912
915
913
// Enable the cross-process lock for refreshes, if needs be.
916
- self . deferred_enable_cross_process_refresh_lock ( ) . await ?;
914
+ self . enable_cross_process_lock ( ) . await . map_err ( OidcError :: from) ?;
915
+
916
+ #[ cfg( feature = "e2e-encryption" ) ]
917
+ self . client . encryption ( ) . run_initialization_tasks ( None ) . await ;
918
+
919
+ Ok ( ( ) )
920
+ }
921
+
922
+ pub ( crate ) async fn enable_cross_process_lock (
923
+ & self ,
924
+ ) -> Result < ( ) , CrossProcessRefreshLockError > {
925
+ // Enable the cross-process lock for refreshes, if needs be.
926
+ self . deferred_enable_cross_process_refresh_lock ( ) . await ;
917
927
918
928
if let Some ( cross_process_manager) = self . ctx ( ) . cross_process_token_refresh_manager . get ( ) {
919
929
if let Some ( tokens) = self . session_tokens ( ) {
920
- let mut cross_process_guard = cross_process_manager
921
- . spin_lock ( )
922
- . await
923
- . map_err ( |err| crate :: Error :: Oidc ( err. into ( ) ) ) ?;
930
+ let mut cross_process_guard = cross_process_manager. spin_lock ( ) . await ?;
924
931
925
932
if cross_process_guard. hash_mismatch {
926
933
// At this point, we're finishing a login while another process had written
@@ -932,16 +939,10 @@ impl Oidc {
932
939
) ;
933
940
}
934
941
935
- cross_process_guard
936
- . save_in_memory_and_db ( & tokens)
937
- . await
938
- . map_err ( |err| crate :: Error :: Oidc ( err. into ( ) ) ) ?;
942
+ cross_process_guard. save_in_memory_and_db ( & tokens) . await ?;
939
943
}
940
944
}
941
945
942
- #[ cfg( feature = "e2e-encryption" ) ]
943
- self . client . encryption ( ) . run_initialization_tasks ( None ) . await ;
944
-
945
946
Ok ( ( ) )
946
947
}
947
948
0 commit comments