Skip to content

Commit

Permalink
update dep
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Jan 13, 2020
1 parent b426e3a commit edeb6c5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
16 changes: 4 additions & 12 deletions client/serve_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ var (
chPair chan pair
chReadable chan *smux.Stream
chComplete chan gaio.OpResult
watcher *gaio.Watcher
sessions sync.Map
)

func loopGaio() {
go func() {
for {
res, err := watcher.WaitIO()
res, err := gaio.WaitIO()
if err != nil {
return
}
Expand All @@ -52,20 +51,19 @@ func loopGaio() {
delete(binds, stream)
return
}
watcher.Write(stream, conn, buf[:nr])
gaio.Write(stream, conn, buf[:nr])
}

for {
select {
case res := <-chComplete:
switch res.Op {
switch res.Operation {
case gaio.OpWrite:
defaultAllocator.Put(res.Buffer)
stream := res.Context.(*smux.Stream)

if res.Err != nil { // write failed
if res.Error != nil { // write failed
stream.Close()
res.Conn.Close()
delete(binds, stream)
continue
}
Expand Down Expand Up @@ -108,15 +106,9 @@ func handleClient(session *smux.Session, p1 net.Conn, quiet bool) {

// global async-io
gaioInit.Do(func() {
w, err := gaio.NewWatcher(bufSize)
if err != nil {
panic(err)
}

chComplete = make(chan gaio.OpResult)
chReadable = make(chan *smux.Stream)
chPair = make(chan pair)
watcher = w

go loopGaio()
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect
github.com/tjfoc/gmsm v1.0.1 // indirect
github.com/urfave/cli v1.21.0
github.com/xtaci/gaio v1.0.13
github.com/xtaci/gaio v1.0.17
github.com/xtaci/kcp-go v5.4.20+incompatible
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae // indirect
github.com/xtaci/smux v1.5.7
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ github.com/xtaci/gaio v1.0.12 h1:RQY9iwQmdERtayTeKwsl5GEEkQE360vVSVui1dm8fjo=
github.com/xtaci/gaio v1.0.12/go.mod h1:rJMerwiLCLnKa14YTM/sRggTPrnBZrlCg9U3DnV5VBE=
github.com/xtaci/gaio v1.0.13 h1:tct3DLhs9p4tZjt/U5KFL2+6WXszNG13LaTVBenGVGo=
github.com/xtaci/gaio v1.0.13/go.mod h1:rJMerwiLCLnKa14YTM/sRggTPrnBZrlCg9U3DnV5VBE=
github.com/xtaci/gaio v1.0.17 h1:QzQ72go73JEDrsb9c1vB5FOKUDzxbQH8fIA2wqen8D8=
github.com/xtaci/gaio v1.0.17/go.mod h1:rJMerwiLCLnKa14YTM/sRggTPrnBZrlCg9U3DnV5VBE=
github.com/xtaci/kcp-go v5.4.20+incompatible h1:TN1uey3Raw0sTz0Fg8GkfM0uH3YwzhnZWQ1bABv5xAg=
github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE=
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=
Expand Down

0 comments on commit edeb6c5

Please sign in to comment.