From ff1c40dde37ce2528d4f8463fbf4a722304ad32c Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Fri, 26 Apr 2024 11:52:35 +0800 Subject: [PATCH] Revert "Try wait for only one direction" This reverts commit 34c3ad77773a13fe4d52bffb6378b27ec8823842. --- core/switch.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/switch.go b/core/switch.go index 668c7e9..7c7426f 100644 --- a/core/switch.go +++ b/core/switch.go @@ -24,19 +24,17 @@ func (self *SimpleSwitch) Run() { defer close(self.done[1]) self.switchTraffic(self.port[1], self.port[0]) }() - select { - case <-self.done[0]: - return - case <-self.done[1]: - return - } + <-self.done[0] + <-self.done[1] } func (self *SimpleSwitch) switchTraffic(in, out Port) { for { var b iovec.IoVec if err := in.Unpack(&b); err != nil { - if err != io.EOF { + if err == io.EOF { + out.CloseWrite() + } else { log.Println(err) } return