v1.7.4 Ignore signals in send and sendto

This commit is contained in:
seajee
2025-12-13 16:12:56 +01:00
parent 8c0ccb628e
commit 077bd91f98

8
sock.h
View File

@@ -4,7 +4,7 @@
# @@@@@@ # # @@@@@@ #
# @ @ # # @ @ #
# @====@ # # @====@ #
# @ @ sock.h - v1.7.3 # # @ @ sock.h - v1.7.4 #
# @ @ MIT License # # @ @ MIT License #
# @@% .@ @ # # @@% .@ @ #
# @@ @ @ https://github.com/seajee/sock.h # # @@ @ @ https://github.com/seajee/sock.h #
@@ -578,7 +578,7 @@ ssize_t sock_send(Sock *sock, const void *buf, size_t size)
} }
while (true) { while (true) {
ssize_t n = send(sock->fd, buf, size, 0); ssize_t n = send(sock->fd, buf, size, MSG_NOSIGNAL);
if (n < 0) { if (n < 0) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
@@ -677,7 +677,8 @@ ssize_t sock_sendto(Sock *sock, const void *buf, size_t size, SockAddr addr)
} }
while (true) { while (true) {
ssize_t n = sendto(sock->fd, buf, size, 0, &addr.sockaddr, addr.len); ssize_t n = sendto(sock->fd, buf, size, MSG_NOSIGNAL, &addr.sockaddr,
addr.len);
if (n < 0) { if (n < 0) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
@@ -820,6 +821,7 @@ void sock__convert_addr(SockAddr *addr)
/* /*
Revision history: Revision history:
1.7.4 (2025-12-13) Ignore signals in send and sendto
1.7.3 (2025-09-20) Changed sock_send_all() signature; drain buffers on 1.7.3 (2025-09-20) Changed sock_send_all() signature; drain buffers on
sock_close() to prevent data loss sock_close() to prevent data loss
1.7.2 (2025-09-17) New functions sock_recv_all() and sock_send_all(); 1.7.2 (2025-09-17) New functions sock_recv_all() and sock_send_all();