aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-08-03 08:45:33 +0800
committerFelix Lange <fjl@twurst.com>2015-08-04 09:10:27 +0800
commit5c949d3b3ba81ea0563575b19a7b148aeac4bf61 (patch)
tree05b9bbc8b837081cde166694d040ca1d9c972f45 /p2p
parentbf48ed32dd8be6bec2931c9f1eee4fd749affa21 (diff)
downloadgo-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.tar
go-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.tar.gz
go-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.tar.bz2
go-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.tar.lz
go-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.tar.xz
go-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.tar.zst
go-tangerine-5c949d3b3ba81ea0563575b19a7b148aeac4bf61.zip
fdtrack: temporary hack for tracking file descriptor usage
Package fdtrack logs statistics about open file descriptors. This should help identify the source of #1549.
Diffstat (limited to 'p2p')
-rw-r--r--p2p/dial.go2
-rw-r--r--p2p/discover/udp.go3
-rw-r--r--p2p/metrics.go8
-rw-r--r--p2p/server.go3
4 files changed, 11 insertions, 5 deletions
diff --git a/p2p/dial.go b/p2p/dial.go
index 0fd3a4cf5..8b210bacd 100644
--- a/p2p/dial.go
+++ b/p2p/dial.go
@@ -23,6 +23,7 @@ import (
"net"
"time"
+ "github.com/ethereum/go-ethereum/fdtrack"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p/discover"
@@ -212,6 +213,7 @@ func (t *dialTask) Do(srv *Server) {
glog.V(logger.Detail).Infof("dial error: %v", err)
return
}
+ fd = fdtrack.WrapConn("p2p", fd)
mfd := newMeteredConn(fd, false)
srv.setupConn(mfd, t.flags, t.dest)
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index 4e6ecaf23..d7ca9000d 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -25,6 +25,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/fdtrack"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -197,6 +198,7 @@ func ListenUDP(priv *ecdsa.PrivateKey, laddr string, natm nat.Interface, nodeDBP
if err != nil {
return nil, err
}
+ fdtrack.Open("p2p")
conn, err := net.ListenUDP("udp", addr)
if err != nil {
return nil, err
@@ -234,6 +236,7 @@ func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, nodeDBPath strin
func (t *udp) close() {
close(t.closing)
+ fdtrack.Close("p2p")
t.conn.Close()
// TODO: wait for the loops to end.
}
diff --git a/p2p/metrics.go b/p2p/metrics.go
index f98cac274..8ee4ed04b 100644
--- a/p2p/metrics.go
+++ b/p2p/metrics.go
@@ -34,7 +34,7 @@ var (
// meteredConn is a wrapper around a network TCP connection that meters both the
// inbound and outbound network traffic.
type meteredConn struct {
- *net.TCPConn // Network connection to wrap with metering
+ net.Conn
}
// newMeteredConn creates a new metered connection, also bumping the ingress or
@@ -45,13 +45,13 @@ func newMeteredConn(conn net.Conn, ingress bool) net.Conn {
} else {
egressConnectMeter.Mark(1)
}
- return &meteredConn{conn.(*net.TCPConn)}
+ return &meteredConn{conn}
}
// Read delegates a network read to the underlying connection, bumping the ingress
// traffic meter along the way.
func (c *meteredConn) Read(b []byte) (n int, err error) {
- n, err = c.TCPConn.Read(b)
+ n, err = c.Conn.Read(b)
ingressTrafficMeter.Mark(int64(n))
return
}
@@ -59,7 +59,7 @@ func (c *meteredConn) Read(b []byte) (n int, err error) {
// Write delegates a network write to the underlying connection, bumping the
// egress traffic meter along the way.
func (c *meteredConn) Write(b []byte) (n int, err error) {
- n, err = c.TCPConn.Write(b)
+ n, err = c.Conn.Write(b)
egressTrafficMeter.Mark(int64(n))
return
}
diff --git a/p2p/server.go b/p2p/server.go
index ba83c5503..7351a2654 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -25,6 +25,7 @@ import (
"sync"
"time"
+ "github.com/ethereum/go-ethereum/fdtrack"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p/discover"
@@ -372,7 +373,7 @@ func (srv *Server) startListening() error {
}
laddr := listener.Addr().(*net.TCPAddr)
srv.ListenAddr = laddr.String()
- srv.listener = listener
+ srv.listener = fdtrack.WrapListener("p2p", listener)
srv.loopWG.Add(1)
go srv.listenLoop()
// Map the TCP listening port if NAT is configured.