@@ -584,41 +584,6 @@ netcore_probe_for_module_nofail (MonoImage *image, const char *file_name, int fl
584
584
return result ;
585
585
}
586
586
587
- static MonoDl *
588
- netcore_lookup_self_native_handle (void )
589
- {
590
- ERROR_DECL (load_error );
591
- if (!internal_module )
592
- internal_module = mono_dl_open_self (load_error );
593
-
594
- if (!internal_module )
595
- mono_trace (G_LOG_LEVEL_INFO , MONO_TRACE_DLLIMPORT , "DllImport error loading library '__Internal': '%s'." , mono_error_get_message_without_fields (load_error ));
596
-
597
- mono_trace (G_LOG_LEVEL_DEBUG , MONO_TRACE_DLLIMPORT , "Native library found via __Internal." );
598
- mono_error_cleanup (load_error );
599
-
600
- return internal_module ;
601
- }
602
-
603
- static MonoDl * native_handle_lookup_wrapper (gpointer handle )
604
- {
605
- MonoDl * result = NULL ;
606
-
607
- if (!internal_module )
608
- netcore_lookup_self_native_handle ();
609
-
610
- if (internal_module -> handle == handle ) {
611
- result = internal_module ;
612
- }
613
- else {
614
- native_library_lock ();
615
- result = netcore_handle_lookup (handle );
616
- native_library_unlock ();
617
- }
618
-
619
- return result ;
620
- }
621
-
622
587
static MonoDl *
623
588
netcore_resolve_with_dll_import_resolver (MonoAssemblyLoadContext * alc , MonoAssembly * assembly , const char * scope , guint32 flags , MonoError * error )
624
589
{
@@ -666,7 +631,9 @@ netcore_resolve_with_dll_import_resolver (MonoAssemblyLoadContext *alc, MonoAsse
666
631
mono_runtime_invoke_checked (resolve , NULL , args , error );
667
632
goto_if_nok (error , leave );
668
633
669
- result = native_handle_lookup_wrapper (lib );
634
+ native_library_lock ();
635
+ result = netcore_handle_lookup (lib );
636
+ native_library_unlock ();
670
637
671
638
leave :
672
639
HANDLE_FUNCTION_RETURN_VAL (result );
@@ -721,7 +688,9 @@ netcore_resolve_with_load (MonoAssemblyLoadContext *alc, const char *scope, Mono
721
688
mono_runtime_invoke_checked (resolve , NULL , args , error );
722
689
goto_if_nok (error , leave );
723
690
724
- result = native_handle_lookup_wrapper (lib );
691
+ native_library_lock ();
692
+ result = netcore_handle_lookup (lib );
693
+ native_library_unlock ();
725
694
726
695
leave :
727
696
HANDLE_FUNCTION_RETURN_VAL (result );
@@ -786,7 +755,9 @@ netcore_resolve_with_resolving_event (MonoAssemblyLoadContext *alc, MonoAssembly
786
755
mono_runtime_invoke_checked (resolve , NULL , args , error );
787
756
goto_if_nok (error , leave );
788
757
789
- result = native_handle_lookup_wrapper (lib );
758
+ native_library_lock ();
759
+ result = netcore_handle_lookup (lib );
760
+ native_library_unlock ();
790
761
791
762
leave :
792
763
HANDLE_FUNCTION_RETURN_VAL (result );
@@ -831,6 +802,22 @@ netcore_check_alc_cache (MonoAssemblyLoadContext *alc, const char *scope)
831
802
return result ;
832
803
}
833
804
805
+ static MonoDl *
806
+ netcore_lookup_self_native_handle (void )
807
+ {
808
+ ERROR_DECL (load_error );
809
+ if (!internal_module )
810
+ internal_module = mono_dl_open_self (load_error );
811
+
812
+ if (!internal_module )
813
+ mono_trace (G_LOG_LEVEL_INFO , MONO_TRACE_DLLIMPORT , "DllImport error loading library '__Internal': '%s'." , mono_error_get_message_without_fields (load_error ));
814
+
815
+ mono_trace (G_LOG_LEVEL_DEBUG , MONO_TRACE_DLLIMPORT , "Native library found via __Internal." );
816
+ mono_error_cleanup (load_error );
817
+
818
+ return internal_module ;
819
+ }
820
+
834
821
static MonoDl *
835
822
netcore_lookup_native_library (MonoAssemblyLoadContext * alc , MonoImage * image , const char * scope , guint32 flags )
836
823
{
0 commit comments