diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-09 12:53:12 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-09 12:53:12 -0400 |
commit | 365548a29f23f15632305d65070236cfd270589c (patch) | |
tree | 398adb2168354ef19b84eba464b327c8011997f0 | |
parent | a00f93e745b588d8bb55a7af7b8b94a2ff5adca0 (diff) |
fix small bug
-rw-r--r-- | pkg/ipstack/ipstack.go | 7 | ||||
-rw-r--r-- | pkg/ipstack/ipstack_test.go | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go index 7b67d08..c993a7d 100644 --- a/pkg/ipstack/ipstack.go +++ b/pkg/ipstack/ipstack.go @@ -132,7 +132,7 @@ func Initialize(lnxFilePath string) error { if err != nil { return errors.WithMessage(err, "Error creating UDP socket for neighbor->\t"+neighbor.DestAddr.String()) } - go InterfaceListenerRoutine(n.SendSocket, n.SocketChannel) + // go InterfaceListenerRoutine(n.SendSocket, n.SocketChannel) myNeighbors[neighbor.InterfaceName] = append(myNeighbors[neighbor.InterfaceName], n) @@ -180,8 +180,8 @@ func InterfaceListenerRoutine(socket net.UDPConn, signal <-chan bool) { for { select { - case open, sig := <-signal: - if !open { + case sig, ok := <-signal: + if !ok { fmt.Println("channel closed, exiting") closed = true return @@ -189,6 +189,7 @@ func InterfaceListenerRoutine(socket net.UDPConn, signal <-chan bool) { fmt.Println("received isUP SIGNAL with value", sig) isUp = sig default: + continue } } } diff --git a/pkg/ipstack/ipstack_test.go b/pkg/ipstack/ipstack_test.go index 97c4947..ddb5453 100644 --- a/pkg/ipstack/ipstack_test.go +++ b/pkg/ipstack/ipstack_test.go @@ -75,17 +75,22 @@ func TestInterfaceUpThenDownTwice(t *testing.T) { time.Sleep(5 * time.Millisecond) // allow time to print + fmt.Println("putting interface down") InterfaceDown(iface) if iface.State == true { t.Error("iface state should be false") } + time.Sleep(3 * time.Millisecond) + fmt.Println("putting interface back up") + InterfaceUp(iface) if iface.State == false { t.Error("iface state should be true") } time.Sleep(3 * time.Millisecond) // allow time to print + fmt.Println("putting interface down") InterfaceDown(iface) if iface.State == true { t.Error("iface state should be false") |