From ca180893827f51408e5bb35aecf8be7413c69d2f Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 15 Oct 2019 15:55:08 +0100 Subject: [PATCH] Fix bugs related to needing to send Broadcast --- tunnel/default.go | 2 +- tunnel/session.go | 6 +++--- tunnel/tunnel.go | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tunnel/default.go b/tunnel/default.go index fe63fe26..38f0f100 100644 --- a/tunnel/default.go +++ b/tunnel/default.go @@ -326,7 +326,7 @@ func (t *tun) process() { } // check the multicast mappings - if msg.mode > Unicast { + if msg.mode == Multicast { link.RLock() _, ok := link.channels[msg.channel] link.RUnlock() diff --git a/tunnel/session.go b/tunnel/session.go index 0cd3bcce..a185c3ce 100644 --- a/tunnel/session.go +++ b/tunnel/session.go @@ -125,7 +125,7 @@ func (s *session) Open() error { } // don't wait on multicast/broadcast - if s.mode > Unicast { + if s.mode == Multicast { s.accepted = true return nil } @@ -163,7 +163,7 @@ func (s *session) Accept() error { } // don't wait on multicast/broadcast - if s.mode > Unicast { + if s.mode == Multicast { return nil } @@ -223,7 +223,7 @@ func (s *session) Send(m *transport.Message) error { msg.data = data // if multicast don't set the link - if s.mode > Unicast { + if s.mode == Multicast { msg.link = "" } diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 8b9b347a..f46c90b8 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -9,8 +9,11 @@ import ( ) const ( + // send over one link Unicast Mode = iota + // send to all channel listeners Multicast + // send to all listeners Broadcast ) @@ -25,6 +28,7 @@ var ( ErrLinkNotFound = errors.New("link not found") ) +// Mode of the session type Mode uint8 // Tunnel creates a gre tunnel on top of the go-micro/transport.