Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Dec 31, 2019
1 parent 6d2eb3e commit 56995b3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/serve_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ func loopGaio() {
}
buf := defaultAllocator.Get(size)
nr, er := stream.TryRead(buf)
if er == nil {
watcher.Write(fd, buf[:nr], chTx, stream)
if er != nil { // read error, delete
delete(binds, stream)
return
}
watcher.Write(fd, buf[:nr], chTx, stream)
}

for {
Expand Down Expand Up @@ -100,8 +102,8 @@ func handleClient(session *smux.Session, p1 net.Conn, quiet bool) {
}
}

// global async-io
gaioInit.Do(func() {
// control struct init
w, err := gaio.CreateWatcher(gaioBufferSize)
if err != nil {
panic(err)
Expand Down Expand Up @@ -132,10 +134,10 @@ func handleClient(session *smux.Session, p1 net.Conn, quiet bool) {
logln("stream opened", "in:", p1.RemoteAddr(), "out:", fmt.Sprint(p2.RemoteAddr(), "(", p2.ID(), ")"))
defer logln("stream closed", "in:", p1.RemoteAddr(), "out:", fmt.Sprint(p2.RemoteAddr(), "(", p2.ID(), ")"))

// pair gaio
// p2 -> p1, async method
chPair <- pair{p1, p2}

// start tunnel & wait for tunnel termination
// p1 -> p2, blocking method
streamCopy := func(dst io.Writer, src io.ReadCloser) {
if _, err := generic.Copy(dst, src); err != nil {
// report protocol error
Expand Down

0 comments on commit 56995b3

Please sign in to comment.