From: Guus Sliepen Date: Thu, 27 Jul 2017 08:06:13 +0000 (+0200) Subject: Forward-port tinc 1.0's handling of device errors. X-Git-Tag: release-1.1pre15~9 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=e4544dbc6989e4a146c19519924e52c116bfc343;p=tinc Forward-port tinc 1.0's handling of device errors. --- diff --git a/src/net_packet.c b/src/net_packet.c index 71f02a1e..ed04a85d 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1573,10 +1573,19 @@ void handle_device_data(void *data, int flags) { vpn_packet_t packet; packet.offset = DEFAULT_PACKET_OFFSET; packet.priority = 0; + static int errors = 0; if(devops.read(&packet)) { + errors = 0; myself->in_packets++; myself->in_bytes += packet.len; route(myself, &packet); + } else { + usleep(errors * 50000); + errors++; + if(errors > 10) { + logger(DEBUG_ALWAYS, LOG_ERR, "Too many errors from %s, exiting!", device); + event_exit(); + } } }