提交 c7e3183d 作者: Juan Batiz-Benet

Merge pull request #1148 from ipfs/warnOnProtocolEOF

only warn about io.EOF from mux.ReaderHeaders (fixes #1143)
package basichost package basichost
import ( import (
"io"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...@@ -95,7 +97,11 @@ func (h *BasicHost) newConnHandler(c inet.Conn) { ...@@ -95,7 +97,11 @@ func (h *BasicHost) newConnHandler(c inet.Conn) {
func (h *BasicHost) newStreamHandler(s inet.Stream) { func (h *BasicHost) newStreamHandler(s inet.Stream) {
protoID, handle, err := h.Mux().ReadHeader(s) protoID, handle, err := h.Mux().ReadHeader(s)
if err != nil { if err != nil {
log.Error("protocol mux failed: %s", err) if err == io.EOF {
log.Debugf("protocol EOF: %s", s.Conn().RemotePeer())
} else {
log.Warning("protocol mux failed: %s", err)
}
return return
} }
...@@ -114,7 +120,7 @@ func (h *BasicHost) Peerstore() peer.Peerstore { ...@@ -114,7 +120,7 @@ func (h *BasicHost) Peerstore() peer.Peerstore {
return h.Network().Peerstore() return h.Network().Peerstore()
} }
// Networks returns the Network interface of the Host // Network returns the Network interface of the Host
func (h *BasicHost) Network() inet.Network { func (h *BasicHost) Network() inet.Network {
return h.network return h.network
} }
...@@ -124,6 +130,7 @@ func (h *BasicHost) Mux() *protocol.Mux { ...@@ -124,6 +130,7 @@ func (h *BasicHost) Mux() *protocol.Mux {
return h.mux return h.mux
} }
// IDService returns
func (h *BasicHost) IDService() *identify.IDService { func (h *BasicHost) IDService() *identify.IDService {
return h.ids return h.ids
} }
...@@ -136,6 +143,7 @@ func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler ...@@ -136,6 +143,7 @@ func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler
h.Mux().SetHandler(pid, handler) h.Mux().SetHandler(pid, handler)
} }
// RemoveStreamHandler returns ..
func (h *BasicHost) RemoveStreamHandler(pid protocol.ID) { func (h *BasicHost) RemoveStreamHandler(pid protocol.ID) {
h.Mux().RemoveHandler(pid) h.Mux().RemoveHandler(pid)
} }
...@@ -232,6 +240,7 @@ func (h *BasicHost) Close() error { ...@@ -232,6 +240,7 @@ func (h *BasicHost) Close() error {
return h.proc.Close() return h.proc.Close()
} }
// GetBandwidthReporter exposes the Host's bandiwth metrics reporter
func (h *BasicHost) GetBandwidthReporter() metrics.Reporter { func (h *BasicHost) GetBandwidthReporter() metrics.Reporter {
return h.bwc return h.bwc
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论