Skip to content

Commit

Permalink
Remove Idle_timeout enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
HBaghdadi1995 committed Mar 14, 2019
1 parent 4ff6b32 commit 1d1d0ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/ConnectionPool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ mutable struct Connection{T <: IO}
peerport::UInt16 # debug only
localport::UInt16 # debug only
io::T
idle_timeout_enabled::Bool
buffer::IOBuffer
sequence::Int
writecount::Int
Expand All @@ -96,13 +95,13 @@ end

Connection(host::AbstractString, port::AbstractString,
pipeline_limit::Int, idle_timeout::Int,
require_ssl_verification::Bool, io::T, idle_timeout_enabled = true) where T <: IO =
require_ssl_verification::Bool, io::T) where T <: IO =
Connection{T}(host, port,
pipeline_limit, idle_timeout,
require_ssl_verification,
peerport(io), localport(io),
io, idle_timeout_enabled,
PipeBuffer(), -1,
io, PipeBuffer(),
-1,
0, false, Condition(),
0, false, Condition(),
time())
Expand All @@ -124,7 +123,7 @@ getrawstream(t::Transaction) = t.c.io
inactiveseconds(t::Transaction) = inactiveseconds(t.c)

function inactiveseconds(c::Connection)::Float64
if !c.readbusy && !c.writebusy || !c.idle_timeout_enabled
if !c.readbusy && !c.writebusy
return 0.0
end
return time() - c.timestamp
Expand Down Expand Up @@ -457,8 +456,7 @@ function purge()
if c.idle_timeout > 0 &&
!c.readbusy &&
!c.writebusy &&
time() - c.timestamp > c.idle_timeout &&
c.idle_timeout_enabled
time() - c.timestamp > c.idle_timeout

close(c.io) ;@debug 1 "⌛️ Timeout: $c"
end
Expand Down
8 changes: 3 additions & 5 deletions src/Servers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ function listen(f,
connection_count::Ref{Int}=Ref(0),
rate_limit::Union{Rational{Int}, Nothing}=nothing,
reuse_limit::Int=nolimit,
verbose::Bool=false,
idle_timeout_enabled = true)
readtimeout::Int=0,
verbose::Bool=false)

inet = getinet(host, port)
if server !== nothing
Expand All @@ -223,15 +222,15 @@ function listen(f,

s = Server(sslconfig, tcpserver, string(host), string(port))
return listenloop(f, s, tcpisvalid, connection_count,
reuse_limit, readtimeout, verbose, idle_timeout_enabled)
reuse_limit, readtimeout, verbose)
end

""""
Main server loop.
Accepts new tcp connections and spawns async tasks to handle them."
"""
function listenloop(f, server, tcpisvalid, connection_count,
reuse_limit, readtimeout, verbose, idle_timeout_enabled = true)
reuse_limit, readtimeout, verbose)
count = 1
while isopen(server)
try
Expand All @@ -244,7 +243,6 @@ function listenloop(f, server, tcpisvalid, connection_count,
connection_count[] += 1
conn = Connection(io)
conn.host, conn.port = server.hostname, server.hostport
conn.idle_timeout_enabled = idle_timeout_enabled
let io=io, count=count
@async try
verbose && @info "Accept ($count): $conn"
Expand Down
2 changes: 1 addition & 1 deletion src/WebSockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function listen(f::Function,
host::String="localhost", port::UInt16=UInt16(8081);
binary=false, verbose=false)

HTTP.listen(host, port; verbose=verbose, idle_timeout_enabled = false) do http
HTTP.listen(host, port; verbose=verbose) do http
upgrade(f, http; binary=binary)
end
end
Expand Down

0 comments on commit 1d1d0ef

Please sign in to comment.