Skip to content

Commit

Permalink
Add synchronized block to protect against race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
alsutton committed Jan 20, 2021
1 parent 545548d commit f7e10d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions java/com/facebook/soloader/SoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ public static void init(Context context, int flags, @Nullable SoFileLoader soFil
isSystemApp = checkIfSystemApp(context, flags);
initSoLoader(soFileLoader);
initSoSources(context, flags, soFileLoader);
if (!NativeLoader.isInitialized()) {
NativeLoader.init(new NativeLoaderToSoLoaderDelegate());
synchronized(NativeLoader.class) {
if (!NativeLoader.isInitialized()) {
NativeLoader.init(new NativeLoaderToSoLoaderDelegate());
}
}
} finally {
StrictMode.setThreadPolicy(oldPolicy);
Expand Down

0 comments on commit f7e10d5

Please sign in to comment.