mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-20 22:10:30 +00:00
Refactor: remove some code that is now unnecessary
- don't need another wrapper round `conntrack.Connections()` - logPipe() was only for the command-line conntrack - nobody closes the `event` chan now, so no need to pre-check for quit
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package endpoint
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@@ -102,20 +100,10 @@ func (c *conntrackWalker) clearFlows() {
|
||||
c.activeFlows = map[uint32]conntrack.Conn{}
|
||||
}
|
||||
|
||||
func logPipe(prefix string, reader io.Reader) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
log.Error(prefix, scanner.Text())
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Error(prefix, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *conntrackWalker) run() {
|
||||
existingFlows, err := c.existingConnections()
|
||||
existingFlows, err := conntrack.ConnectionsSize(c.bufferSize)
|
||||
if err != nil {
|
||||
log.Errorf("conntrack existingConnections error: %v", err)
|
||||
log.Errorf("conntrack Connections error: %v", err)
|
||||
return
|
||||
}
|
||||
for _, flow := range existingFlows {
|
||||
@@ -128,17 +116,6 @@ func (c *conntrackWalker) run() {
|
||||
return
|
||||
}
|
||||
|
||||
c.Lock()
|
||||
// We may have stopped in the mean time,
|
||||
// so check to see if the channel is open
|
||||
// under the lock.
|
||||
select {
|
||||
default:
|
||||
case <-c.quit:
|
||||
return
|
||||
}
|
||||
c.Unlock()
|
||||
|
||||
defer log.Infof("conntrack exiting")
|
||||
|
||||
// Handle conntrack events from netlink socket
|
||||
@@ -156,14 +133,6 @@ func (c *conntrackWalker) run() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *conntrackWalker) existingConnections() ([]conntrack.Conn, error) {
|
||||
flows, err := conntrack.ConnectionsSize(c.bufferSize)
|
||||
if err != nil {
|
||||
return []conntrack.Conn{}, err
|
||||
}
|
||||
return flows, nil
|
||||
}
|
||||
|
||||
func (c *conntrackWalker) stop() {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user