mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Merge pull request #2020 from kinvolk/alban/fix-getWalkedProcPid
procspy: use a Reader to copy the background reader buffer
This commit is contained in:
@@ -46,7 +46,10 @@ func (br *backgroundReader) getWalkedProcPid(buf *bytes.Buffer) (map[uint64]*Pro
|
||||
br.mtx.Lock()
|
||||
defer br.mtx.Unlock()
|
||||
|
||||
_, err := io.Copy(buf, br.latestBuf)
|
||||
// Don't access latestBuf directly but create a reader. In this way,
|
||||
// the buffer will not be empty in the next call of getWalkedProcPid
|
||||
// and it can be copied again.
|
||||
_, err := io.Copy(buf, bytes.NewReader(br.latestBuf.Bytes()))
|
||||
|
||||
return br.latestSockets, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user