Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining server verbosity logs #1193

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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"

Check warning on line 392 in src/Servers.jl

View check run for this annotation

Codecov / codecov/patch

src/Servers.jl#L392

Added line #L392 was not covered by tests
close(io)
continue
end
Expand All @@ -398,17 +398,17 @@
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 @@
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)

Check warning on line 434 in src/Servers.jl

View check run for this annotation

Codecov / codecov/patch

src/Servers.jl#L434

Added line #L434 was not covered by tests
end
try
# if the connection socket or listener close, we stop taking requests
Expand Down Expand Up @@ -499,7 +499,7 @@
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 @@
"""
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)

Check warning on line 519 in src/Servers.jl

View check run for this annotation

Codecov / codecov/patch

src/Servers.jl#L519

Added line #L519 was not covered by tests
while wait_for_timeout[]
if inactiveseconds(c) > readtimeout
@warnv 2 "Connection Timeout: $c"
verbose >= 0 && @warn "Connection Timeout: $c"

Check warning on line 522 in src/Servers.jl

View check run for this annotation

Codecov / codecov/patch

src/Servers.jl#L522

Added line #L522 was not covered by tests
try
writeheaders(c, Response(408, ["Connection" => "close"]))
finally
Expand Down
Loading