Only log the errors from observers
Because we call the observers concurrently, we must not write to S.err inside the goroutines. For now, we simply log an error from an observer.
This commit is contained in:
parent
65a8d52b7a
commit
6eebe8c9f4
@ -102,8 +102,7 @@ func (S *Scanner) OnFound(fun Observer) {
|
|||||||
//
|
//
|
||||||
// Run will return an error if it couldn't read the proc filesystem. Otherwise
|
// Run will return an error if it couldn't read the proc filesystem. Otherwise
|
||||||
// it will try to continue to loop over all pids, writing potential errors to
|
// it will try to continue to loop over all pids, writing potential errors to
|
||||||
// the console. Errors from the observer functions are also logged and the
|
// the console. Errors from the observer functions are logged.
|
||||||
// final such error is the return value of Run().
|
|
||||||
func (S *Scanner) Run() error {
|
func (S *Scanner) Run() error {
|
||||||
if S.err != nil {
|
if S.err != nil {
|
||||||
return S.err
|
return S.err
|
||||||
@ -141,8 +140,8 @@ func (S *Scanner) Run() error {
|
|||||||
go func() {
|
go func() {
|
||||||
err = observer(pid, offset)
|
err = observer(pid, offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
S.setErrorf("S.observer[%d] error: %v", n, err)
|
S.Printf("S.observer[%d](%d, %d) error: %v", n, pid, offset, err)
|
||||||
// TODO: propagate errors from all Observers.
|
// TODO: accumulate errors from all Observers.
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user