You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/12/06 11:25:32 UTC

[GitHub] cxfeng1 closed pull request #1875: [iOS] Protect multithread set/get custom environment.

cxfeng1 closed pull request #1875: [iOS] Protect multithread set/get custom environment.
URL: https://github.com/apache/incubator-weex/pull/1875
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
index 47a2880c60..3671d6d9af 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
@@ -299,15 +299,21 @@ + (WXSDKInstance *)topInstance
 }
 
 
-static NSDictionary *_customEnvironment;
+static NSDictionary *_customEnvironment = nil;
 + (void)setCustomEnvironment:(NSDictionary *)environment
 {
-    _customEnvironment = environment;
+    @synchronized (self) {
+        _customEnvironment = environment;
+    }
 }
 
 + (NSDictionary *)customEnvironment
 {
-    return _customEnvironment;
+    NSDictionary* result = nil;
+    @synchronized (self) {
+        result = _customEnvironment;
+    }
+    return result;
 }
 
 # pragma mark Debug
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index 2e6f9a7243..47f0d003e2 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -227,8 +227,9 @@ + (NSDictionary *)getEnvironment
         }
     }
     
-    if ([WXSDKEngine customEnvironment]) {
-        [data addEntriesFromDictionary:[WXSDKEngine customEnvironment]];
+    NSDictionary* customEnvironment = [WXSDKEngine customEnvironment];
+    if (customEnvironment) {
+        [data addEntriesFromDictionary:customEnvironment];
     }
     
     return data;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services