Skip to content
Snippets Groups Projects
Commit 0f16c0f4 authored by Cameron Sparr's avatar Cameron Sparr
Browse files

Reduce TCP listener allocations

parent 30464396
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
### Features
- [#976](https://github.com/influxdata/telegraf/pull/976): Reduce allocations in the UDP and statsd inputs.
- [#979](https://github.com/influxdata/telegraf/pull/979): Reduce allocations in the TCP listener.
### Bugfixes
- [#968](https://github.com/influxdata/telegraf/issues/968): Processes plugin gets unknown state when spaces are in (command name)
......
......@@ -39,7 +39,7 @@ type TcpListener struct {
acc telegraf.Accumulator
}
var dropwarn = "ERROR: Message queue full. Discarding line [%s] " +
var dropwarn = "ERROR: Message queue full. Discarding metric. " +
"You may want to increase allowed_pending_messages in the config\n"
const sampleConfig = `
......@@ -202,11 +202,10 @@ func (t *TcpListener) handler(conn *net.TCPConn, id string) {
if !scanner.Scan() {
return
}
buf := scanner.Bytes()
select {
case t.in <- buf:
case t.in <- scanner.Bytes():
default:
log.Printf(dropwarn, string(buf))
log.Printf(dropwarn)
}
}
}
......@@ -215,11 +214,12 @@ func (t *TcpListener) handler(conn *net.TCPConn, id string) {
// tcpParser parses the incoming tcp byte packets
func (t *TcpListener) tcpParser() error {
defer t.wg.Done()
var packet []byte
for {
select {
case <-t.done:
return nil
case packet := <-t.in:
case packet = <-t.in:
if len(packet) == 0 {
continue
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment