From 54af87bc6ca93c7be489797a54e5fce5ed553439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sat, 10 Aug 2024 11:09:34 +0200 Subject: [PATCH] Fix race condition with request offer timer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/NCCallController.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/NextcloudTalk/NCCallController.m b/NextcloudTalk/NCCallController.m index b87340d61..dc527b073 100644 --- a/NextcloudTalk/NCCallController.m +++ b/NextcloudTalk/NCCallController.m @@ -1079,16 +1079,16 @@ - (void)requestOfferWithRepetitionForSessionId:(NSString *)sessionId andRoomType [userInfo setObject:roomType forKey:@"roomType"]; [userInfo setValue:timeout forKey:@"timeout"]; + NSTimer *pendingOfferTimer = [NSTimer timerWithTimeInterval:8.0 target:self selector:@selector(requestNewOffer:) userInfo:userInfo repeats:YES]; + NSString *peerKey = [sessionId stringByAppendingString:roomType]; + + [self->_pendingOffersDict setObject:pendingOfferTimer forKey:peerKey]; + // Request new offer [self->_externalSignalingController requestOfferForSessionId:sessionId andRoomType:roomType]; - // Set timeout to request new offer - dispatch_async(dispatch_get_main_queue(), ^{ - NSTimer *pendingOfferTimer = [NSTimer scheduledTimerWithTimeInterval:8.0 target:self selector:@selector(requestNewOffer:) userInfo:userInfo repeats:YES]; - NSString *peerKey = [sessionId stringByAppendingString:roomType]; - [[WebRTCCommon shared] dispatch:^{ - [self->_pendingOffersDict setObject:pendingOfferTimer forKey:peerKey]; - }]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSRunLoop mainRunLoop] addTimer:pendingOfferTimer forMode:NSDefaultRunLoopMode]; }); }