Skip to content

Commit

Permalink
Fail fast on connection errors.
Browse files Browse the repository at this point in the history
The fix for #4 in f221c3c was still not right.

It worked I think for the pure go backends, but for the nfdump backend
that uses exec, it was triggering the error inside of exec before the
flush even happened.
  • Loading branch information
JustinAzoff committed Mar 28, 2018
1 parent 0018572 commit 2ad9abb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions flowindexer/flowindexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"regexp"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -410,6 +411,9 @@ func (i *Indexer) Dump(query string, writer io.Writer) error {
}
if err != nil {
log.Printf("Error dumping %q: %q", fn, err)
if isBrokenPipe(err) {
return err
}
}
}
return err
Expand Down Expand Up @@ -460,3 +464,9 @@ func RunDaemon(config string) {
}

}

//isBrokenPipe determines if an error was a broken pipe or connection reset error
//This is really the wrong way to do this, but the right way was not working either.
func isBrokenPipe(err error) bool {
return strings.Contains(err.Error(), "broken pipe") || strings.Contains(err.Error(), "connection")
}

0 comments on commit 2ad9abb

Please sign in to comment.