From e029c9f96105fb83b6a4cdc2ee647d094fb282b4 Mon Sep 17 00:00:00 2001 From: Aleksey Belouosv Date: Mon, 18 Mar 2019 14:54:31 +0300 Subject: [PATCH] [iOS] fix HttpSessionManager synchronization --- platform/http_session_manager.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/http_session_manager.mm b/platform/http_session_manager.mm index 1aaebf93fd..ec8d748b01 100644 --- a/platform/http_session_manager.mm +++ b/platform/http_session_manager.mm @@ -80,7 +80,14 @@ - (void)setDataTaskInfo:(DataTaskInfo *)taskInfo forTask:(NSURLSessionTask *)task { dispatch_barrier_sync(self.taskInfoQueue, ^{ - self.taskInfoByTaskID[task] = taskInfo; + self.taskInfoByTaskID[@(task.taskIdentifier)] = taskInfo; + }); +} + +- (void)removeTaskInfoForTask:(NSURLSessionTask *)task +{ + dispatch_barrier_sync(self.taskInfoQueue, ^{ + [self.taskInfoByTaskID removeObjectForKey:@(task.taskIdentifier)]; }); } @@ -88,7 +95,7 @@ { __block DataTaskInfo * taskInfo = nil; dispatch_sync(self.taskInfoQueue, ^{ - taskInfo = self.taskInfoByTaskID[task]; + taskInfo = self.taskInfoByTaskID[@(task.taskIdentifier)]; }); return taskInfo; @@ -123,7 +130,7 @@ didCompleteWithError:(NSError *)error { DataTaskInfo * taskInfo = [self taskInfoForTask:task]; - [self.taskInfoByTaskID removeObjectForKey:@(taskInfo.task.taskIdentifier)]; + [self removeTaskInfoForTask:task]; if ([taskInfo.delegate respondsToSelector:@selector(URLSession:task:didCompleteWithError:)]) {