Skip to content

Commit

Permalink
fix a goroutine leak issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jarod committed Oct 12, 2013
1 parent 1a12542 commit a5052bc
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions fsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ func (fs *FspServer) handleConnection(conn *net.TCPConn) {
if !ok {
return
}
case <-fs.timeout(time.Second * 2):
case <-time.After(time.Second * 2):
log.Println("Timeout reading from", conn.RemoteAddr().String())
return
}

w := bufio.NewWriterSize(conn, len(fs.policyData))
w.Write(fs.policyData)
w.Flush()
conn.Write(fs.policyData)
log.Println("Sent policy file to", conn.RemoteAddr().String())
}

Expand All @@ -89,12 +86,3 @@ func (fs *FspServer) read(conn *net.TCPConn) (c chan bool) {
}()
return
}

func (fs *FspServer) timeout(d time.Duration) (c chan bool) {
c = make(chan bool)
go func() {
time.Sleep(d)
c <- true
}()
return
}

0 comments on commit a5052bc

Please sign in to comment.