feat: add ENOBUFS (no buff space left) to EAGAIN error behavior
This commit is contained in:
parent
f2edfed48b
commit
23c5256c76
2 changed files with 9 additions and 7 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -8,15 +8,16 @@ send_to_destination(struct icmp_handle *h, const void *packet, size_t len,
|
|||
struct in_addr dest, uint8_t ttl)
|
||||
{
|
||||
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);
|
||||
|
||||
if (0 == ret)
|
||||
icmp_clear_error(h);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue