Warn about tunnel buffer being full only once per second

Otherwise, when the network output bandwidth is full, we additionally
fill the disk with logs.
This commit is contained in:
Samuel Thibault 2023-04-25 19:23:52 +02:00
parent b0a93e8809
commit 7fd81113e6

View file

@ -1301,7 +1301,20 @@ void tunnelsend(uint8_t * buf, uint16_t l, tunnelidt t)
if (sendto(udpfd[tunnel[t].indexudp], buf, l, 0, (void *) &addr, sizeof(addr)) < 0) if (sendto(udpfd[tunnel[t].indexudp], buf, l, 0, (void *) &addr, sizeof(addr)) < 0)
{ {
LOG(0, ntohs((*(uint16_t *) (buf + 6))), t, "Error sending data out tunnel: %s (udpfd=%d, buf=%p, len=%d, dest=%s)\n", sessionidt s = ntohs((*(uint16_t *) (buf + 6)));
if (errno == EAGAIN)
{
static time_t lastwarn;
time_t newtime = time(NULL);
if (lastwarn != newtime)
{
lastwarn = newtime;
LOG(0, 0, t, "Error sending data out tunnel: buffer full\n");
}
}
else
LOG(0, s, t, "Error sending data out tunnel: %s (udpfd=%d, buf=%p, len=%d, dest=%s)\n",
strerror(errno), udpfd[tunnel[t].indexudp], buf, l, inet_ntoa(addr.sin_addr)); strerror(errno), udpfd[tunnel[t].indexudp], buf, l, inet_ntoa(addr.sin_addr));
STAT(tunnel_tx_errors); STAT(tunnel_tx_errors);
return; return;