Skip to content

Commit

Permalink
Fix remaining server verbosity logs (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj authored Nov 8, 2024
1 parent 1e92b1a commit 66a2dbf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Servers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,17 @@ function listenloop(
conns_lock, verbose
)
sem = Base.Semaphore(max_connections)
verbose >= 0 && @infov 1 "Listening on: $(listener.hostname):$(listener.hostport), thread id: $(Threads.threadid())"
verbose >= 0 && @info "Listening on: $(listener.hostname):$(listener.hostport), thread id: $(Threads.threadid())"
notify(ready_to_accept)
while isopen(listener)
try
Base.acquire(sem)
io = accept(listener)
if io === nothing
@warnv 1 "unable to accept new connection"
verbose >= 0 && @warn "unable to accept new connection"
continue
elseif !tcpisvalid(io)
@warnv 1 "!tcpisvalid: $io"
verbose >= 0 && @warn "!tcpisvalid: $io"
close(io)
continue
end
Expand All @@ -398,17 +398,17 @@ function listenloop(
Base.@lock conns_lock push!(conns, conn)
conn.host, conn.port = listener.hostname, listener.hostport
@async try
handle_connection(f, conn, listener, readtimeout, access_log)
handle_connection(f, conn, listener, readtimeout, access_log, verbose)
finally
# handle_connection is in charge of closing the underlying io
Base.@lock conns_lock delete!(conns, conn)
Base.release(sem)
end
catch e
if e isa Base.IOError && e.code == Base.UV_ECONNABORTED
verbose >= 0 && @infov 1 "Server on $(listener.hostname):$(listener.hostport) closing"
verbose >= 0 && @info "Server on $(listener.hostname):$(listener.hostport) closing"
else
@errorv 2 begin
verbose >= 1 && @error begin
msg = current_exceptions_to_string()
"Server on $(listener.hostname):$(listener.hostport) errored. $msg"
end
Expand All @@ -428,10 +428,10 @@ for each HTTP Request received.
After `reuse_limit + 1` transactions, signal `final_transaction` to the
transaction handler, which will close the connection.
"""
function handle_connection(f, c::Connection, listener, readtimeout, access_log)
function handle_connection(f, c::Connection, listener, readtimeout, access_log, verbose)
wait_for_timeout = Ref{Bool}(true)
if readtimeout > 0
@async check_readtimeout(c, readtimeout, wait_for_timeout)
@async check_readtimeout(c, readtimeout, wait_for_timeout, verbose)
end
try
# if the connection socket or listener close, we stop taking requests
Expand Down Expand Up @@ -499,7 +499,7 @@ function handle_connection(f, c::Connection, listener, readtimeout, access_log)
end
catch
# we should be catching everything inside the while loop, but just in case
@errorv 1 begin
verbose >= 0 && @error begin
msg = current_exceptions_to_string()
"error while handling connection. $msg"
end
Expand All @@ -516,10 +516,10 @@ end
"""
If `c` is inactive for a more than `readtimeout` then close the `c`."
"""
function check_readtimeout(c, readtimeout, wait_for_timeout)
function check_readtimeout(c, readtimeout, wait_for_timeout, verbose)
while wait_for_timeout[]
if inactiveseconds(c) > readtimeout
@warnv 2 "Connection Timeout: $c"
verbose >= 0 && @warn "Connection Timeout: $c"
try
writeheaders(c, Response(408, ["Connection" => "close"]))
finally
Expand Down

0 comments on commit 66a2dbf

Please sign in to comment.