Skip to content

Commit

Permalink
Fix keep-alive
Browse files Browse the repository at this point in the history
Rule activity wasn't updated on data packets incoming
  • Loading branch information
Darkren committed Dec 20, 2019
1 parent a1c63f3 commit 6f46ff1
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 12 deletions.
9 changes: 5 additions & 4 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,16 @@ func (r *router) handleKeepAlivePacket(_ context.Context, packet routing.Packet)

r.logger.Infof("Received keepalive packet for route ID %v", routeID)

rule, err := r.GetRule(routeID)

_, err := r.GetRule(routeID)
if err != nil {
return err
}

r.logger.Infof("Route ID %v found, updating activity", routeID)
// TODO: propagate keep-alive packet down the chain

r.logger.Infof("Route ID %v found, updated activity", routeID)

return r.SaveRoutingRules(rule)
return nil
}

// GetRule gets routing rule.
Expand Down
8 changes: 5 additions & 3 deletions pkg/routing/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ func (mt *memTable) SaveRule(rule Rule) error {
}

func (mt *memTable) Rule(key RouteID) (Rule, error) {
mt.RLock()
rule, ok := mt.rules[key]
mt.RUnlock()
mt.Lock()
defer mt.Unlock()

rule, ok := mt.rules[key]
if !ok {
return nil, fmt.Errorf("rule of id %v not found", key)
}
Expand All @@ -136,6 +136,8 @@ func (mt *memTable) Rule(key RouteID) (Rule, error) {
return nil, ErrRuleTimedOut
}

mt.activity[key] = time.Now()

return rule, nil
}

Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/alecthomas/template/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/alecthomas/units/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vendor/github.com/creack/pty/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/google/uuid/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/gorilla/handlers/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/mattn/go-colorable/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/mattn/go-colorable/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/mattn/go-isatty/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/prometheus/procfs/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/sirupsen/logrus/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/gopkg.in/yaml.v2/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/gopkg.in/yaml.v2/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f46ff1

Please sign in to comment.