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

Error checking in nagle and quickack #32292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions stdlib/Sockets/src/Sockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,12 @@ Enables or disables Nagle's algorithm on a given TCP server or socket.
"""
function nagle(sock::Union{TCPServer, TCPSocket}, enable::Bool)
# disable or enable Nagle's algorithm on all OSes
ccall(:uv_tcp_nodelay, Cint, (Ptr{Cvoid}, Cint), sock.handle, Cint(!enable))
r = ccall(:uv_tcp_nodelay, Cint, (Ptr{Cvoid}, Cint), sock.handle, Cint(!enable))
if r < 0
enable_disable = ifelse(enable, "enable", "disable")
error_string = Libc.strerror(Libc.errno())
@warn "Cannot $(enable_disable) Nagle's algorithm" maxlog=1 exception=error_string
end
end

"""
Expand All @@ -490,7 +495,12 @@ function quickack(sock::Union{TCPServer, TCPSocket}, enable::Bool)
@static if Sys.islinux()
# tcp_quickack is a linux only option
if ccall(:jl_tcp_quickack, Cint, (Ptr{Cvoid}, Cint), sock.handle, Cint(enable)) < 0
@warn "Networking unoptimized ( Error enabling TCP_QUICKACK : $(Libc.strerror(Libc.errno())) )" maxlog=1
error_string = Libc.strerror(Libc.errno())
if enable
@warn "Networking unoptimized (error enabling TCP_QUICKACK)" maxlog=1 exception=error_string
else
@warn "Error disabling TCP_QUICKACK" maxlog=1 exception=error_string
end
end
end
end
Expand Down