feat: add ENOBUFS (no buff space left) to EAGAIN error behavior

This commit is contained in:
lohhiiccc 2026-04-22 13:22:33 +02:00
parent f2edfed48b
commit a9bdaf33f2
2 changed files with 12 additions and 7 deletions

View file

@ -37,11 +37,12 @@ handle_send_error(struct icmp_handle *h)
int saved_errno;
saved_errno = errno;
if (EAGAIN == saved_errno || EWOULDBLOCK == saved_errno)
if (EAGAIN == saved_errno || EWOULDBLOCK == saved_errno
|| ENOBUFS == saved_errno)
{
icmp_set_error_fmt(h, ICMP_ERR_EAGAIN,
"Send would block (buffer full, retry later)");
return -1;
return 1;
}
icmp_set_error_fmt(h, ICMP_ERR_SEND, "sendto() failed: %s",
strerror(saved_errno));

View file

@ -7,16 +7,20 @@ int
send_to_destination(struct icmp_handle *h, const void *packet, size_t len,
struct in_addr dest, uint8_t ttl)
{
struct sockaddr_in addr;
struct sockaddr_in addr;
int ret;
if (send_set_socket_ttl(h, ttl) < 0)
return -1;
send_prepare_destination(&addr, dest);
if (send_packet(h, packet, len, &addr) < 0)
return -1;
ret = send_packet(h, packet, len, &addr);
icmp_clear_error(h);
return 0;
switch (ret)
{
case -1: return -1;
case 1: return 1;
default: icmp_clear_error(h); return 0;
}
}