Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,7 @@ func (c *client) processSubEx(subject, queue, bsid []byte, cb msgHandler, noForw
return sub, nil
}

if err := c.addShadowSubscriptions(acc, sub, true); err != nil {
if err := c.addShadowSubscriptions(acc, sub); err != nil {
c.Errorf(err.Error())
}

Expand Down Expand Up @@ -3052,10 +3052,7 @@ type ime struct {
// If the client's account has stream imports and there are matches for this
// subscription's subject, then add shadow subscriptions in the other accounts
// that export this subject.
//
// enact=false allows MQTT clients to get the list of shadow subscriptions
// without enacting them, in order to first obtain matching "retained" messages.
func (c *client) addShadowSubscriptions(acc *Account, sub *subscription, enact bool) error {
func (c *client) addShadowSubscriptions(acc *Account, sub *subscription) error {
if acc == nil {
return ErrMissingAccount
}
Expand Down Expand Up @@ -3158,7 +3155,7 @@ func (c *client) addShadowSubscriptions(acc *Account, sub *subscription, enact b
for i := 0; i < len(ims); i++ {
ime := &ims[i]
// We will create a shadow subscription.
nsub, err := c.addShadowSub(sub, ime, enact)
nsub, err := c.addShadowSub(sub, ime)
if err != nil {
return err
}
Expand All @@ -3175,7 +3172,7 @@ func (c *client) addShadowSubscriptions(acc *Account, sub *subscription, enact b
}

// Add in the shadow subscription.
func (c *client) addShadowSub(sub *subscription, ime *ime, enact bool) (*subscription, error) {
func (c *client) addShadowSub(sub *subscription, ime *ime) (*subscription, error) {
c.mu.Lock()
nsub := *sub // copy
c.mu.Unlock()
Expand Down Expand Up @@ -3203,10 +3200,6 @@ func (c *client) addShadowSub(sub *subscription, ime *ime, enact bool) (*subscri
}
// Else use original subject

if !enact {
return &nsub, nil
}

c.Debugf("Creating import subscription on %q from account %q", nsub.subject, im.acc.Name)

if err := im.acc.sl.Insert(&nsub); err != nil {
Expand Down Expand Up @@ -5796,7 +5789,7 @@ func (c *client) processSubsOnConfigReload(awcsti map[string]struct{}) {
oldShadows := sub.shadow
sub.shadow = nil
c.mu.Unlock()
c.addShadowSubscriptions(acc, sub, true)
c.addShadowSubscriptions(acc, sub)
for _, nsub := range oldShadows {
nsub.im.acc.sl.Remove(nsub)
}
Expand Down
2 changes: 1 addition & 1 deletion server/leafnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ func (c *client) processLeafSub(argo []byte) (err error) {

// Only add in shadow subs if a new sub or qsub.
if osub == nil {
if err := c.addShadowSubscriptions(acc, sub, true); err != nil {
if err := c.addShadowSubscriptions(acc, sub); err != nil {
c.Errorf(err.Error())
}
}
Expand Down
Loading