From 42409f7f228083dad788efd4ed3cc96d26712c6f Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 13 Jul 2011 20:57:12 +0200 Subject: pingu: try bind socket to interface every burst It might be an interface that disappeared and came back, e.g ppp0. We also don't even try unless we have a successful binding. --- pingu_burst.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'pingu_burst.c') diff --git a/pingu_burst.c b/pingu_burst.c index 7cc5b9a..3c3fe5b 100644 --- a/pingu_burst.c +++ b/pingu_burst.c @@ -10,12 +10,20 @@ #include "pingu_burst.h" #include "pingu_host.h" #include "pingu_ping.h" +#include "pingu_iface.h" void ping_burst_start(struct ev_loop *loop, struct pingu_host *host) { struct addrinfo hints; struct addrinfo *ai, *rp; int r; + + /* we bind to device every burst in case an iface disappears and + comes back. e.g ppp0 */ + if (pingu_iface_bind_socket(host->iface, host->status) < 0) { + pingu_host_set_status(host, 0); + return; + } host->burst.active = 1; host->burst.pings_sent = 0; @@ -31,7 +39,7 @@ void ping_burst_start(struct ev_loop *loop, struct pingu_host *host) for (rp = ai; rp != NULL; rp = rp->ai_next) { host->burst.saddr = *ai->ai_addr; - r = pingu_ping_send(loop, host); + r = pingu_ping_send(loop, host, 0); if (r == 0) break; } -- cgit v1.2.3