fix possible race condition

This commit is contained in:
Erik 2016-02-11 09:36:36 -05:00
parent 750ba138e1
commit 0f70079382
2 changed files with 7 additions and 6 deletions

View File

@ -202,9 +202,12 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb
postSendClose(nil, nil, nil)
} else {
// We need to take special care when we're polling that we send it ASAP
postWait.append(String(SocketEnginePacketType.Close.rawValue))
let req = createRequestForPostWithPostWait()
doRequest(req, withCallback: postSendClose)
// Also make sure we're on the emitQueue since we're touching postWait
dispatch_sync(emitQueue) {
self.postWait.append(String(SocketEnginePacketType.Close.rawValue))
let req = self.createRequestForPostWithPostWait()
self.doRequest(req, withCallback: postSendClose)
}
}
}

View File

@ -214,9 +214,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
}
func didDisconnect(reason: String) {
guard status != .Closed else {
return
}
guard status != .Closed else { return }
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)