From 309db6515bf42ef31283edd210548091d7d01e38 Mon Sep 17 00:00:00 2001 From: liyang Date: Mon, 16 Jan 2023 15:57:53 +0800 Subject: [PATCH] fix over-release issue about Token and Hosts of QNServerConfigSynchronizer --- QiniuSDK/Storage/ServerConfig/QNServerConfigSynchronizer.m | 7 +++++++ 1 file changed, 7 insertions(+) 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 {