Skip to content

Commit

Permalink
Fixed a bug where Replicant was crashing due to calling invalidate on…
Browse files Browse the repository at this point in the history
… a nil timer
  • Loading branch information
Dr. Brandon Wiley committed Feb 7, 2019
1 parent 2dae914 commit 3ce2100
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Sources/Replicant/ReplicantConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ open class ReplicantConnection: Connection
self.sendBuffer = self.sendBuffer[unencryptedChunkSize...]

// Turn off the timer
self.sendTimer!.invalidate()
self.sendTimer = nil
if self.sendTimer != nil
{
self.sendTimer!.invalidate()
self.sendTimer = nil
}

// Keep calling network.send if the leftover data is at least chunk size
self.network.send(content: maybeEncryptedData, contentContext: contentContext, isComplete: isComplete, completion: NWConnection.SendCompletion.contentProcessed(
Expand All @@ -156,8 +159,11 @@ open class ReplicantConnection: Connection
if let error = maybeError
{
print("Received an error on Send:\(error)")
self.sendTimer!.invalidate()
self.sendTimer = nil
if self.sendTimer != nil
{
self.sendTimer!.invalidate()
self.sendTimer = nil
}

switch completion
{
Expand Down

0 comments on commit 3ce2100

Please sign in to comment.