Skip to content

Commit feb476c

Browse files
committed
Added comments to document changes reasons
1 parent b258a93 commit feb476c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Source/SocketIO/Engine/SocketEngine.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
359359
///
360360
/// **You shouldn't call this directly**
361361
open func doFastUpgrade() {
362+
362363
if waitingForPoll {
363364
DefaultSocketLogger.Logger.error("Outstanding poll when switched to WebSockets," +
364365
"we'll probably disconnect soon. You should report this.", type: SocketEngine.logType)
@@ -371,7 +372,10 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
371372
fastUpgrade = false
372373
probing = false
373374
flushProbeWait()
374-
if postWait.count != 0 {
375+
376+
// Need to flush postWait to socket since it connected successfully
377+
// (moved from flushProbeWait() since it is also called on connected failure)
378+
if !postWait.isEmpty {
375379
flushWaitingForPostToWebSocket()
376380
}
377381
}

Source/SocketIO/Manager/SocketManager.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
168168
DefaultSocketLogger.Logger.log("Adding engine", type: SocketManager.logType)
169169

170170
engine?.engineQueue.sync {
171+
171172
self.engine?.client = nil
173+
174+
// Close old engine so it will not leak because of URLSession if in polling mode
172175
self.engine?.disconnect(reason: "Adding new engine")
173176
}
174177

0 commit comments

Comments
 (0)