mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
fix(net): add NOSIGNAL to send options
This is a better default than not having it, since it turns errors that would be signals into error values instead. We could take these as options but given that we currently don't I think this at the very least improves on the status quo.
This commit is contained in:
@@ -136,6 +136,7 @@ TCP_Send_Error :: enum c.int {
|
|||||||
Interrupted = c.int(linux.Errno.EINTR), // A signal occurred before any data was transmitted. See signal(7).
|
Interrupted = c.int(linux.Errno.EINTR), // A signal occurred before any data was transmitted. See signal(7).
|
||||||
Timeout = c.int(linux.Errno.EWOULDBLOCK), // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout.
|
Timeout = c.int(linux.Errno.EWOULDBLOCK), // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout.
|
||||||
Not_Socket = c.int(linux.Errno.ENOTSOCK), // The so-called socket is not an open socket.
|
Not_Socket = c.int(linux.Errno.ENOTSOCK), // The so-called socket is not an open socket.
|
||||||
|
Broken_Pipe = c.int(linux.Errno.EPIPE), // The peer has disconnected when we are trying to send to it
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ _send_tcp :: proc(tcp_sock: TCP_Socket, buf: []byte) -> (int, Network_Error) {
|
|||||||
for total_written < len(buf) {
|
for total_written < len(buf) {
|
||||||
limit := min(int(max(i32)), len(buf) - total_written)
|
limit := min(int(max(i32)), len(buf) - total_written)
|
||||||
remaining := buf[total_written:][:limit]
|
remaining := buf[total_written:][:limit]
|
||||||
res, errno := linux.send(linux.Fd(tcp_sock), remaining, {})
|
res, errno := linux.send(linux.Fd(tcp_sock), remaining, {.NOSIGNAL})
|
||||||
if errno != .NONE {
|
if errno != .NONE {
|
||||||
return total_written, TCP_Send_Error(errno)
|
return total_written, TCP_Send_Error(errno)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user