Skip to content

Commit

Permalink
Merge pull request #3453 from GoNZooo/gonz.add-nosignal-broken-pipe
Browse files Browse the repository at this point in the history
fix(net/linux): add `NOSIGNAL` to `send` options
  • Loading branch information
gingerBill authored Apr 19, 2024
2 parents d84b298 + 68f663e commit 3620e62
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/net/socket_linux.odin
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ _send_tcp :: proc(tcp_sock: TCP_Socket, buf: []byte) -> (int, Network_Error) {
for total_written < len(buf) {
limit := min(int(max(i32)), len(buf) - total_written)
remaining := buf[total_written:][:limit]
res, errno := linux.send(linux.Fd(tcp_sock), remaining, {})
if errno != .NONE {
res, errno := linux.send(linux.Fd(tcp_sock), remaining, {.NOSIGNAL})
if errno == .EPIPE {
// If the peer is disconnected when we are trying to send we will get an `EPIPE` error,
// so we turn that into a clearer error
return total_written, TCP_Send_Error.Connection_Closed
} else if errno != .NONE {
return total_written, TCP_Send_Error(errno)
}
total_written += int(res)
Expand Down

0 comments on commit 3620e62

Please sign in to comment.