Skip to content

Commit

Permalink
all: Do not use connection state in peer call
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Apr 7, 2023
1 parent d9f4919 commit 1d21fc0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ For details about compatibility between different releases, see the **Commitment

- Attempting to claim an end device with a generated DevEUI will now result in an error.
- Claiming an end device using command line flags.
- 24 hour stack components deadlock when the default clustering mode is used.

## [3.25.0] - 2023-04-05

Expand Down
3 changes: 1 addition & 2 deletions cmd/ttn-lw-cli/internal/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"go.thethings.network/lorawan-stack/v3/pkg/rpcmiddleware/rpclog"
"go.thethings.network/lorawan-stack/v3/pkg/rpcmiddleware/rpcretry"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
)

Expand Down Expand Up @@ -184,7 +183,7 @@ func CloseAll() {
defer connMu.Unlock()
for target, conn := range conns {
delete(conns, target)
if conn == nil || conn.GetState() == connectivity.Shutdown {
if conn == nil {
continue
}
conn.Close()
Expand Down
9 changes: 3 additions & 6 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"go.thethings.network/lorawan-stack/v3/pkg/random"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
)

Expand Down Expand Up @@ -317,18 +316,16 @@ func (c *cluster) Leave() error {
}

func (c *cluster) GetPeers(ctx context.Context, role ttnpb.ClusterRole) ([]Peer, error) {
var matches []Peer
matches := make([]Peer, 0, len(c.peers))
for _, peer := range c.peers {
if !peer.HasRole(role) {
continue
}
conn, err := peer.Conn()
_, err := peer.Conn()
if err != nil {
continue
}
if conn.GetState() == connectivity.Ready {
matches = append(matches, peer)
}
matches = append(matches, peer)
}
return matches, nil
}
Expand Down

0 comments on commit 1d21fc0

Please sign in to comment.