Skip to content

Commit

Permalink
fixed cluster query which would answer our own requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindar committed Nov 11, 2017
1 parent 493a13c commit 1e8b9e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions broker/cluster/swarm.go
Expand Up @@ -244,6 +244,11 @@ func (s *Swarm) OnGossip(buf []byte) (delta mesh.GossipData, err error) {
// OnGossipBroadcast merges received data into state and returns a representation
// of the received data (typically a delta) for further propagation.
func (s *Swarm) OnGossipBroadcast(src mesh.PeerName, buf []byte) (delta mesh.GossipData, err error) {
if src == s.name {
logging.LogAction("merge", "got our own broadcast")
return
}

if delta, err = s.merge(buf); err != nil {
logging.LogError("merge", "merging", err)
}
Expand Down
2 changes: 1 addition & 1 deletion broker/conn.go
Expand Up @@ -212,7 +212,7 @@ func (c *Conn) Unsubscribe(ssid message.Ssid, channel []byte) {

// Close terminates the connection.
func (c *Conn) Close() error {
logging.LogTarget("conn", "closed", c.luid)
logging.LogTarget("conn", "closed", c.guid)

This comment has been minimized.

Copy link
@tanelpuhu

tanelpuhu Mar 11, 2018

Hi,

idk if this is worth of creating an issue but i'm just curious - this was changed here from LUID to GUID but line 57, after connection creation,

logging.LogTarget("conn", "created", c.luid)
the LUID is still logged.

wouldn't it be neat to have same id referenced in log and maybe similar log entries could be matched?

2018/03/11 22:23:55 [conn] created (ACF98330)
2018/03/11 22:23:58 [conn] closed (R4KDCEQDRWNPC5SH7GCQRSSMQA)

// Unsubscribe from everything, no need to lock since each Unsubscribe is
// already locked. Locking the 'Close()' would result in a deadlock.
Expand Down
8 changes: 7 additions & 1 deletion broker/query.go
Expand Up @@ -114,8 +114,14 @@ func (c *QueryManager) onRequest(ssid message.Ssid, channel string, payload []by
return err
}

// Do not answer our own requests
replyAddr := mesh.PeerName(reply)
if c.service.cluster.ID() == uint64(replyAddr) {
return nil
}

// Get the peer to reply to
peer := c.service.cluster.FindPeer(mesh.PeerName(reply))
peer := c.service.cluster.FindPeer(replyAddr)

// Go through all the handlers and execute the first matching one
for _, handle := range c.handlers {
Expand Down

0 comments on commit 1e8b9e2

Please sign in to comment.