Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Quit TCP connection if source closes it
Browse files Browse the repository at this point in the history
  • Loading branch information
otoolep committed Sep 3, 2016
1 parent 3dc124d commit fc18397
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions input/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,20 @@ func (s *TCPCollector) handleConnection(conn net.Conn, c chan<- *Event) {
stats.Add("tcpConnReadError", 1)
if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
stats.Add("tcpConnReadTimeout", 1)
log, match = delimiter.Vestige()
} else if err == io.EOF {
stats.Add("tcpConnReadEOF", 1)
log, match = delimiter.Vestige()
} else {
stats.Add("tcpConnUnrecoverError", 1)
return
}

log, match = delimiter.Vestige()
} else {
stats.Add("tcpBytesRead", 1)
log, match = delimiter.Push(b)
}

// Log line available?
if match {
stats.Add("tcpEventsRx", 1)
if s.parser.Parse(bytes.NewBufferString(log).Bytes()) {
Expand All @@ -147,6 +149,11 @@ func (s *TCPCollector) handleConnection(conn net.Conn, c chan<- *Event) {
}
}
}

// Was the connection closed?
if err == io.EOF {
return
}
}
}

Expand Down

0 comments on commit fc18397

Please sign in to comment.