Stop waiting for interface after 5 seconds

This commit is contained in:
Bryan Boreham committed 2014-09-18 05:50:13 +01:00
1 parent a2f725c627
commit e51f89268c
1 file changed
+10 -2
+10 -2
View File
@@ -24,11 +24,15 @@ func ensureInterface(ifaceName string, wait bool) (iface *net.Interface, err err
return
}
log.Println("Waiting for interface", ifaceName, "to come up")
for err != nil {
count := 0
for err != nil && count < 5 {
count += 1
time.Sleep(1 * time.Second)
iface, err = findInterface(ifaceName)
}
log.Println("Interface", ifaceName, "is up")
if err == nil {
log.Println("Interface", ifaceName, "is up")
}
return
}
@@ -47,6 +51,7 @@ func main() {
log.SetPrefix(weave.Protocol + " ")
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)
log.Println(os.Args)
procs := runtime.NumCPU()
// packet sniffing can block an OS thread, so we need one thread
@@ -87,6 +92,9 @@ func main() {
if err != nil {
log.Fatal(err)
}
if wait && iface == nil {
os.Exit(1)
}
if connLimit < 0 {
connLimit = 0