diff --git a/QiniuSDK/Storage/ServerConfig/QNServerConfigSynchronizer.m b/QiniuSDK/Storage/ServerConfig/QNServerConfigSynchronizer.m index ed9c0dff..1823199d 100644 --- a/QiniuSDK/Storage/ServerConfig/QNServerConfigSynchronizer.m +++ b/QiniuSDK/Storage/ServerConfig/QNServerConfigSynchronizer.m @@ -12,7 +12,10 @@ #import "QNResponseInfo.h" #import "QNRequestTransaction.h" #import "QNServerConfigSynchronizer.h" +#import +static pthread_mutex_t qnServerConfigTokenMutexLock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t qnServerConfigHostsMutexLock = PTHREAD_MUTEX_INITIALIZER; static NSString *Token = nil; static NSArray *Hosts = nil; @@ -125,7 +128,9 @@ + (void)destroyServerUserConfigRequestTransaction { } + (void)setToken:(NSString *)token { + pthread_mutex_lock(&qnServerConfigTokenMutexLock); Token = token; + pthread_mutex_unlock(&qnServerConfigTokenMutexLock); } + (NSString *)token { @@ -133,7 +138,9 @@ + (NSString *)token { } + (void)setHosts:(NSArray *)servers { + pthread_mutex_lock(&qnServerConfigHostsMutexLock); Hosts = [servers copy]; + pthread_mutex_lock(&qnServerConfigHostsMutexLock); } + (NSArray *)hosts {