Skip to content

Commit

Permalink
fix(stream): fix panic of 'No recent network activity' (#22)
Browse files Browse the repository at this point in the history
* fix(stream): fix panic of 'NO_ERROR: No recent network activity'
  • Loading branch information
chenjunbiao authored Jul 27, 2020
1 parent b36ec68 commit ca7cfe1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/util/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"log"
"math/big"
"net"
"strings"
"time"

json "github.com/10cella/yomo-json-codec"
Expand Down Expand Up @@ -102,11 +103,22 @@ func QuicServer(endpoint string, plugin plugin.YomoObjectPlugin, codec *json.Cod
for {
sess, err := listener.Accept(context.Background())
if err != nil {
panic(err)
if strings.Index(err.Error(), "NO_ERROR") == 0 {
log.Printf("Accept error: %s", err.Error())
continue
} else {
panic(err)
}
}

stream, err := sess.AcceptStream(context.Background())
if err != nil {
panic(err)
if strings.Index(err.Error(), "NO_ERROR") == 0 {
log.Printf("AcceptStream error: %s", err.Error())
continue
} else {
panic(err)
}
}

go io.Copy(YomoFrameworkStreamWriter{plugin.Name(), codec, plugin, stream}, stream) // nolint
Expand Down

0 comments on commit ca7cfe1

Please sign in to comment.