Skip to content

Commit

Permalink
Better error checking in nagle and quickack
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Jun 12, 2019
1 parent 5d02c59 commit 57896e0
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit 57896e0

Please sign in to comment.