Skip to content

Commit

Permalink
Merge pull request #99 from pushkarnk/sync-keep-alive
Browse files Browse the repository at this point in the history
Synchronize access to the keepAliveState property
  • Loading branch information
Pushkar N Kulkarni authored Oct 15, 2018
2 parents 0d79b8d + d37ef06 commit 214abc9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Sources/KituraNet/HTTP/HTTPRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,24 @@ internal class HTTPRequestHandler: ChannelInboundHandler {
/// We'd want to send an error response only once
var errorResponseSent = false

var keepAliveState: KeepAliveState = .unlimited

var keepAliveState: KeepAliveState {
set {
self.syncQueue.sync {
_keepAliveState = newValue
}
}

get {
return self.syncQueue.sync {
return _keepAliveState
}
}
}

private let syncQueue = DispatchQueue(label: "HTTPServer.keepAliveSync")

private var _keepAliveState: KeepAliveState = .unlimited

static let keepAliveTimeout: TimeInterval = 60

private(set) var clientRequestedKeepAlive = false
Expand Down

0 comments on commit 214abc9

Please sign in to comment.