@@ -31,19 +31,6 @@ use crate::util::types::{catch_panic_response, catch_panic_response_no_default,
3131
3232const STACK_SIZE : usize = 64 << 20 ; // 64MiB
3333
34- #[ derive( Copy , Clone ) ]
35- struct MachinePtr ( * const InnerFvmMachine ) ;
36-
37- // Safety: MachinePtr is only read or written behind a mutex and points to an
38- // InnerFvmMachine that is itself synchronized internally.
39- unsafe impl Send for MachinePtr { }
40-
41- impl Default for MachinePtr {
42- fn default ( ) -> Self {
43- MachinePtr ( std:: ptr:: null ( ) )
44- }
45- }
46-
4734lazy_static ! {
4835 static ref CONCURRENCY : u32 = get_concurrency( ) ;
4936 static ref ENGINES : MultiEngineContainer = MultiEngineContainer :: with_concurrency( * CONCURRENCY ) ;
@@ -53,8 +40,6 @@ lazy_static! {
5340 . prefix( "fvm" )
5441 . stack_size( STACK_SIZE )
5542 ) ;
56- static ref CURRENT_MACHINE : std:: sync:: Mutex <MachinePtr > =
57- std:: sync:: Mutex :: new( MachinePtr :: default ( ) ) ;
5843}
5944
6045const LOTUS_FVM_CONCURRENCY_ENV_NAME : & str = "LOTUS_FVM_CONCURRENCY" ;
@@ -178,14 +163,6 @@ fn create_fvm_machine_generic(
178163 let inner = engine. new_executor ( config, blockstore, externs) ?;
179164 let boxed: repr_c:: Box < InnerFvmMachine > = Box :: new ( inner) . into ( ) ;
180165
181- // Track the most recently created machine for reservation sessions.
182- {
183- let mut current = CURRENT_MACHINE
184- . lock ( )
185- . map_err ( |e| anyhow ! ( "current executor lock poisoned: {e}" ) ) ?;
186- * current = MachinePtr ( & * boxed as * const InnerFvmMachine ) ;
187- }
188-
189166 Ok ( Some ( boxed) )
190167 } )
191168 }
@@ -612,6 +589,7 @@ fn map_reservation_error_to_status(
612589#[ ffi_export]
613590#[ allow( non_snake_case) ]
614591fn FVM_BeginReservations (
592+ executor : & ' _ InnerFvmMachine ,
615593 cbor_plan_ptr : * const u8 ,
616594 cbor_plan_len : usize ,
617595 error_msg_ptr_out : * mut * const u8 ,
@@ -659,31 +637,7 @@ fn FVM_BeginReservations(
659637 }
660638 } ;
661639
662- let machine_ptr = match CURRENT_MACHINE . lock ( ) {
663- Ok ( guard) => guard. 0 ,
664- Err ( _) => {
665- set_reservation_error_message_out (
666- error_msg_ptr_out,
667- error_msg_len_out,
668- "reservation invariant violated: current executor lock poisoned" ,
669- ) ;
670- return FvmReservationStatus :: ErrReservationInvariant ;
671- }
672- } ;
673-
674- if machine_ptr. is_null ( ) {
675- set_reservation_error_message_out (
676- error_msg_ptr_out,
677- error_msg_len_out,
678- "reservations not implemented for current machine" ,
679- ) ;
680- return FvmReservationStatus :: ErrNotImplemented ;
681- }
682-
683- // SAFETY: the pointer is set when the machine is created and
684- // is expected to remain valid while reservations are used.
685- let inner = unsafe { & * machine_ptr } ;
686- let machine_mutex = match & inner. machine {
640+ let machine_mutex = match & executor. machine {
687641 Some ( m) => m,
688642 None => {
689643 set_reservation_error_message_out (
@@ -716,36 +670,13 @@ fn FVM_BeginReservations(
716670#[ ffi_export]
717671#[ allow( non_snake_case) ]
718672fn FVM_EndReservations (
673+ executor : & ' _ InnerFvmMachine ,
719674 error_msg_ptr_out : * mut * const u8 ,
720675 error_msg_len_out : * mut usize ,
721676) -> FvmReservationStatus {
722677 clear_reservation_error_message_out ( error_msg_ptr_out, error_msg_len_out) ;
723678
724- let machine_ptr = match CURRENT_MACHINE . lock ( ) {
725- Ok ( guard) => guard. 0 ,
726- Err ( _) => {
727- set_reservation_error_message_out (
728- error_msg_ptr_out,
729- error_msg_len_out,
730- "reservation invariant violated: current executor lock poisoned" ,
731- ) ;
732- return FvmReservationStatus :: ErrReservationInvariant ;
733- }
734- } ;
735-
736- if machine_ptr. is_null ( ) {
737- set_reservation_error_message_out (
738- error_msg_ptr_out,
739- error_msg_len_out,
740- "reservations not implemented for current machine" ,
741- ) ;
742- return FvmReservationStatus :: ErrNotImplemented ;
743- }
744-
745- // SAFETY: the pointer is set when the machine is created and
746- // is expected to remain valid while reservations are used.
747- let inner = unsafe { & * machine_ptr } ;
748- let machine_mutex = match & inner. machine {
679+ let machine_mutex = match & executor. machine {
749680 Some ( m) => m,
750681 None => {
751682 set_reservation_error_message_out (
0 commit comments