Fix bugs related to needing to send Broadcast

This commit is contained in:
Asim Aslam 2019-10-15 15:55:08 +01:00
parent 7b1f5584ab
commit ca18089382
3 changed files with 8 additions and 4 deletions

View File

@ -326,7 +326,7 @@ func (t *tun) process() {
} }
// check the multicast mappings // check the multicast mappings
if msg.mode > Unicast { if msg.mode == Multicast {
link.RLock() link.RLock()
_, ok := link.channels[msg.channel] _, ok := link.channels[msg.channel]
link.RUnlock() link.RUnlock()

View File

@ -125,7 +125,7 @@ func (s *session) Open() error {
} }
// don't wait on multicast/broadcast // don't wait on multicast/broadcast
if s.mode > Unicast { if s.mode == Multicast {
s.accepted = true s.accepted = true
return nil return nil
} }
@ -163,7 +163,7 @@ func (s *session) Accept() error {
} }
// don't wait on multicast/broadcast // don't wait on multicast/broadcast
if s.mode > Unicast { if s.mode == Multicast {
return nil return nil
} }
@ -223,7 +223,7 @@ func (s *session) Send(m *transport.Message) error {
msg.data = data msg.data = data
// if multicast don't set the link // if multicast don't set the link
if s.mode > Unicast { if s.mode == Multicast {
msg.link = "" msg.link = ""
} }

View File

@ -9,8 +9,11 @@ import (
) )
const ( const (
// send over one link
Unicast Mode = iota Unicast Mode = iota
// send to all channel listeners
Multicast Multicast
// send to all listeners
Broadcast Broadcast
) )
@ -25,6 +28,7 @@ var (
ErrLinkNotFound = errors.New("link not found") ErrLinkNotFound = errors.New("link not found")
) )
// Mode of the session
type Mode uint8 type Mode uint8
// Tunnel creates a gre tunnel on top of the go-micro/transport. // Tunnel creates a gre tunnel on top of the go-micro/transport.