Skip to content

Commit

Permalink
Merge pull request ARMmbed#25 from moogle19/fix_goroutine_leak
Browse files Browse the repository at this point in the history
Fix goroutine leak in linux att server
  • Loading branch information
roylee17 authored Jan 5, 2017
2 parents b01eb98 + b800277 commit 4eb2faa
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions linux/att/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *Server) indicate(h uint16, data []byte) (int, error) {
return n, err
}
select {
case ok := <-s.chConfirm:
case _, ok := <-s.chConfirm:
if !ok {
return 0, io.ErrClosedPipe
}
Expand All @@ -131,7 +131,8 @@ func (s *Server) Loop() {
n, err := s.conn.Read(b.buf)
if n == 0 || err != nil {
close(seq)
s.close()
close(s.chConfirm)
_ = s.conn.Close()
return
}
if b.buf[0] == HandleValueConfirmationCode {
Expand Down Expand Up @@ -168,11 +169,6 @@ func (s *Server) Loop() {
}
}

func (s *Server) close() error {
s.chConfirm <- false
return s.conn.Close()
}

func (s *Server) handleRequest(b []byte) []byte {
var resp []byte
logger.Debug("server", "req", fmt.Sprintf("% X", b))
Expand Down

0 comments on commit 4eb2faa

Please sign in to comment.