Skip to content

Commit

Permalink
Refactor FabricSoLoader to ensure sDidInit is accessed correctly
Browse files Browse the repository at this point in the history
Summary:
sDidInit can be accessed from different threads, this diff refactors the definition of this variable to be volatile and also to be assigned at the end of the staticInit() method.

Changelog:
Ensure proper initialization of FabricSoLoder

Reviewed By: ejanzer

Differential Revision: D18010919

fbshipit-source-id: 3ec7b19fdc15056b90fc01281b8c3888e93a7dd3
  • Loading branch information
mdvacca authored and facebook-github-bot committed Oct 21, 2019
1 parent ff6b2ff commit e21ed67
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
import com.facebook.systrace.Systrace;

public class FabricSoLoader {
private static boolean sDidInit = false;
private static volatile boolean sDidInit = false;

public static void staticInit() {
if (sDidInit) {
return;
}
sDidInit = true;

Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricSoLoader.staticInit::load:fabricjni");
ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START);
SoLoader.loadLibrary("fabricjni");
ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
sDidInit = true;
}
}

0 comments on commit e21ed67

Please sign in to comment.