Skip to content

Commit 3d13368

Browse files
committed
Move reachability change-triggered reconnection restart flag triggering out of the main attempt performing method
1 parent e8ea81f commit 3d13368

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Extensions/Reconnect/XMPPReconnect.m

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,15 @@ static void XMPPReconnectReachabilityCallback(SCNetworkReachabilityRef target, S
358358
@autoreleasepool {
359359

360360
XMPPReconnect *instance = (__bridge XMPPReconnect *)info;
361+
362+
if (instance->previousReachabilityFlags != flags) {
363+
// It's possible that the reachability of our xmpp host has changed in the middle of either
364+
// a reconnection attempt or while querying our delegates for permission to attempt reconnect.
365+
366+
// In such case it makes sense to abort the current reconnection attempt (if any) instead of waiting for it to time out.
367+
[instance setShouldRestartReconnect:YES];
368+
}
369+
361370
[instance maybeAttemptReconnectWithReachabilityFlags:flags];
362371
}
363372
}
@@ -633,19 +642,6 @@ - (void)maybeAttemptReconnectWithReachabilityFlags:(SCNetworkReachabilityFlags)r
633642
{
634643
// The xmpp stream is already attempting a connection.
635644

636-
if (reachabilityFlags != previousReachabilityFlags)
637-
{
638-
// It seems that the reachability of our xmpp host has changed in the middle of either
639-
// a reconnection attempt or while querying our delegates for permission to attempt reconnect.
640-
//
641-
// This may mean that the current attempt will fail,
642-
// but an another attempt after the failure will succeed.
643-
//
644-
// We make a note of the multiple changes,
645-
// and if the current attempt fails, we'll try again after a short delay.
646-
647-
[self setMultipleReachabilityChanges:YES];
648-
}
649645
}
650646
}
651647
}

0 commit comments

Comments
 (0)