Report errors in unicasting gossip

This commit is contained in:
Bryan Boreham committed 2015-06-25 12:22:53 +01:00
1 parent 9a631d0ecd
commit 9f784b3c31
2 files changed
+14 -7

No files matched your search

+2 -2
View File
@@ -575,14 +575,14 @@ func (alloc *Allocator) propose() {
alloc.gossip.GossipBroadcast(alloc.Gossip())
}
func (alloc *Allocator) sendSpaceRequest(dest router.PeerName, r address.Range) {
func (alloc *Allocator) sendSpaceRequest(dest router.PeerName, r address.Range) error {
buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
if err := enc.Encode(r); err != nil {
panic(err)
}
msg := router.Concat([]byte{msgSpaceRequest}, buf.Bytes())
alloc.gossip.GossipUnicast(dest, msg)
return alloc.gossip.GossipUnicast(dest, msg)
}
func (alloc *Allocator) sendRingUpdate(dest router.PeerName) {
+12 -5
View File
@@ -3,6 +3,7 @@ package router
import (
"bytes"
"encoding/gob"
"fmt"
"log"
"sync"
)
@@ -58,7 +59,10 @@ func (c *GossipChannel) deliverUnicast(srcName PeerName, origPayload []byte, dec
return err
}
if c.ourself.Name != destName {
return c.relayUnicast(destName, origPayload)
c.relayUnicast(destName, origPayload)
// ignore errors in passing on data; a problem between us and destination
// is not enough reason to break the connection from the source
return nil
}
var payload []byte
if err := dec.Decode(&payload); err != nil {
@@ -160,15 +164,18 @@ func (c *GossipChannel) GossipBroadcast(update GossipData) error {
return c.relayBroadcast(c.ourself.Name, update)
}
func (c *GossipChannel) relayUnicast(dstPeerName PeerName, buf []byte) error {
func (c *GossipChannel) relayUnicast(dstPeerName PeerName, buf []byte) (err error) {
if relayPeerName, found := c.routes.UnicastAll(dstPeerName); !found {
c.log("unknown relay destination:", dstPeerName)
err = fmt.Errorf("unknown relay destination: %s", dstPeerName)
} else if conn, found := c.ourself.ConnectionTo(relayPeerName); !found {
c.log("unable to find connection to relay peer", relayPeerName)
err = fmt.Errorf("unable to find connection to relay peer %s", relayPeerName)
} else {
conn.(ProtocolSender).SendProtocolMsg(ProtocolMsg{ProtocolGossipUnicast, buf})
}
return nil
if err != nil {
c.log(err)
}
return err
}
func (c *GossipChannel) relayBroadcast(srcName PeerName, update GossipData) error {