|
|
@ -138,24 +138,27 @@ loop: |
|
|
|
// A write finished. Allow the next write to start if
|
|
|
|
// A write finished. Allow the next write to start if
|
|
|
|
// there was no error.
|
|
|
|
// there was no error.
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
glog.V(logger.Detail).Infof("%v: Write error: %v\n", p, err) |
|
|
|
glog.V(logger.Detail).Infof("%v: write error: %v\n", p, err) |
|
|
|
reason = DiscNetworkError |
|
|
|
reason = DiscNetworkError |
|
|
|
break loop |
|
|
|
break loop |
|
|
|
} |
|
|
|
} |
|
|
|
writeStart <- struct{}{} |
|
|
|
writeStart <- struct{}{} |
|
|
|
case err := <-readErr: |
|
|
|
case err := <-readErr: |
|
|
|
if r, ok := err.(DiscReason); ok { |
|
|
|
if r, ok := err.(DiscReason); ok { |
|
|
|
|
|
|
|
glog.V(logger.Debug).Infof("%v: remote requested disconnect: %v\n", p, r) |
|
|
|
|
|
|
|
requested = true |
|
|
|
reason = r |
|
|
|
reason = r |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
glog.V(logger.Detail).Infof("%v: Read error: %v\n", p, err) |
|
|
|
glog.V(logger.Detail).Infof("%v: read error: %v\n", p, err) |
|
|
|
reason = DiscNetworkError |
|
|
|
reason = DiscNetworkError |
|
|
|
} |
|
|
|
} |
|
|
|
break loop |
|
|
|
break loop |
|
|
|
case err := <-p.protoErr: |
|
|
|
case err := <-p.protoErr: |
|
|
|
reason = discReasonForError(err) |
|
|
|
reason = discReasonForError(err) |
|
|
|
|
|
|
|
glog.V(logger.Debug).Infof("%v: protocol error: %v (%v)\n", p, err, reason) |
|
|
|
break loop |
|
|
|
break loop |
|
|
|
case reason = <-p.disc: |
|
|
|
case reason = <-p.disc: |
|
|
|
requested = true |
|
|
|
glog.V(logger.Debug).Infof("%v: locally requested disconnect: %v\n", p, reason) |
|
|
|
break loop |
|
|
|
break loop |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -166,7 +169,6 @@ loop: |
|
|
|
if requested { |
|
|
|
if requested { |
|
|
|
reason = DiscRequested |
|
|
|
reason = DiscRequested |
|
|
|
} |
|
|
|
} |
|
|
|
glog.V(logger.Debug).Infof("%v: Disconnected: %v\n", p, reason) |
|
|
|
|
|
|
|
return reason |
|
|
|
return reason |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -213,7 +215,6 @@ func (p *Peer) handle(msg Msg) error { |
|
|
|
// This is the last message. We don't need to discard or
|
|
|
|
// This is the last message. We don't need to discard or
|
|
|
|
// check errors because, the connection will be closed after it.
|
|
|
|
// check errors because, the connection will be closed after it.
|
|
|
|
rlp.Decode(msg.Payload, &reason) |
|
|
|
rlp.Decode(msg.Payload, &reason) |
|
|
|
glog.V(logger.Debug).Infof("%v: Disconnect Requested: %v\n", p, reason[0]) |
|
|
|
|
|
|
|
return reason[0] |
|
|
|
return reason[0] |
|
|
|
case msg.Code < baseProtocolLength: |
|
|
|
case msg.Code < baseProtocolLength: |
|
|
|
// ignore other base protocol messages
|
|
|
|
// ignore other base protocol messages
|
|
|
|