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

Commit

Permalink
Merge pull request #93 from libp2p/disable-metrics-on-windows
Browse files Browse the repository at this point in the history
disable metrics collection on Windows
  • Loading branch information
marten-seemann authored Sep 7, 2021
2 parents 2329e01 + 7c22df7 commit a8f6d63
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

package tcp

import (
Expand Down Expand Up @@ -250,6 +253,10 @@ type tracingListener struct {
manet.Listener
}

func newTracingListener(l manet.Listener) *tracingListener {
return &tracingListener{Listener: l}
}

func (l *tracingListener) Accept() (manet.Conn, error) {
conn, err := l.Listener.Accept()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions metrics_general.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !linux && !darwin
// +build !linux,!darwin
//go:build !linux && !darwin && !windows
// +build !linux,!darwin,!windows

package tcp

Expand Down
9 changes: 9 additions & 0 deletions metrics_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build windows
// +build windows

package tcp

import manet "github.com/multiformats/go-multiaddr/net"

func newTracingConn(c manet.Conn, _ bool) (manet.Conn, error) { return c, nil }
func newTracingListener(l manet.Listener) manet.Listener { return l }
2 changes: 1 addition & 1 deletion tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (t *TcpTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error) {
if err != nil {
return nil, err
}
list = &tracingListener{&tcpListener{list, 0}}
list = newTracingListener(&tcpListener{list, 0})
return t.Upgrader.UpgradeListener(t, list), nil
}

Expand Down

0 comments on commit a8f6d63

Please sign in to comment.