Skip to content

Commit

Permalink
Fix race condition with request offer timer
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Aug 10, 2024
1 parent f14b034 commit 54af87b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions NextcloudTalk/NCCallController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
});
}

Expand Down

0 comments on commit 54af87b

Please sign in to comment.