Merge branch 'outdated-link-write'
This commit is contained in:
commit
c7af1d3197
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- Deadlock on shutdown (further fixes). [#106](https://github.com/passepartoutvpn/tunnelkit/issues/106)
|
||||
|
||||
## 2.0.2 (2019-07-27)
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -387,7 +387,7 @@ public class OpenVPNSession: Session {
|
|||
private func loopLink() {
|
||||
let loopedLink = link
|
||||
loopedLink?.setReadHandler(queue: queue) { [weak self] (newPackets, error) in
|
||||
guard loopedLink === self?.link else {
|
||||
guard self?.link === loopedLink else {
|
||||
log.warning("Ignoring read from outdated LINK")
|
||||
return
|
||||
}
|
||||
|
@ -1008,13 +1008,18 @@ public class OpenVPNSession: Session {
|
|||
}
|
||||
|
||||
// WARNING: runs in Network.framework queue
|
||||
let writeLink = link
|
||||
link?.writePackets(rawList) { [weak self] (error) in
|
||||
if let error = error {
|
||||
self?.queue.sync {
|
||||
self?.queue.sync {
|
||||
guard self?.link === writeLink else {
|
||||
log.warning("Ignoring write from outdated LINK")
|
||||
return
|
||||
}
|
||||
if let error = error {
|
||||
log.error("Failed LINK write during control flush: \(error)")
|
||||
self?.deferStop(.shutdown, OpenVPNError.failedLinkWrite)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1131,15 +1136,20 @@ public class OpenVPNSession: Session {
|
|||
|
||||
// WARNING: runs in Network.framework queue
|
||||
controlChannel.addSentDataCount(encryptedPackets.flatCount)
|
||||
let writeLink = link
|
||||
link?.writePackets(encryptedPackets) { [weak self] (error) in
|
||||
if let error = error {
|
||||
self?.queue.sync {
|
||||
self?.queue.sync {
|
||||
guard self?.link === writeLink else {
|
||||
log.warning("Ignoring write from outdated LINK")
|
||||
return
|
||||
}
|
||||
if let error = error {
|
||||
log.error("Data: Failed LINK write during send data: \(error)")
|
||||
self?.deferStop(.shutdown, OpenVPNError.failedLinkWrite)
|
||||
return
|
||||
}
|
||||
return
|
||||
// log.verbose("Data: \(encryptedPackets.count) packets successfully written to LINK")
|
||||
}
|
||||
// log.verbose("Data: \(encryptedPackets.count) packets successfully written to LINK")
|
||||
}
|
||||
} catch let e {
|
||||
guard !e.isTunnelKitError() else {
|
||||
|
@ -1172,15 +1182,20 @@ public class OpenVPNSession: Session {
|
|||
}
|
||||
|
||||
// WARNING: runs in Network.framework queue
|
||||
let writeLink = link
|
||||
link?.writePacket(raw) { [weak self] (error) in
|
||||
if let error = error {
|
||||
self?.queue.sync {
|
||||
self?.queue.sync {
|
||||
guard self?.link === writeLink else {
|
||||
log.warning("Ignoring write from outdated LINK")
|
||||
return
|
||||
}
|
||||
if let error = error {
|
||||
log.error("Failed LINK write during send ack for packetId \(controlPacket.packetId): \(error)")
|
||||
self?.deferStop(.shutdown, OpenVPNError.failedLinkWrite)
|
||||
return
|
||||
}
|
||||
return
|
||||
log.debug("Ack successfully written to LINK for packetId \(controlPacket.packetId)")
|
||||
}
|
||||
log.debug("Ack successfully written to LINK for packetId \(controlPacket.packetId)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue