Skip to content

Commit

Permalink
ns: Avoid counting the same error twice
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Sep 14, 2022
1 parent 48f4cb0 commit fcac6b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/networkserver/grpc_gsns.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,6 @@ func (ns *NetworkServer) handleDataUplink(ctx context.Context, up *ttnpb.UplinkM
}
if !ok {
trace.Log(ctx, "ns", "message is duplicate (initial round)")
registerReceiveDuplicateUplink(ctx, up)
return errDuplicateUplink.New()
}
trace.Log(ctx, "ns", "message is original (initial round)")
Expand Down Expand Up @@ -1181,7 +1180,6 @@ func (ns *NetworkServer) handleJoinRequest(ctx context.Context, up *ttnpb.Uplink
}
if !ok {
trace.Log(ctx, "ns", "message is duplicate")
registerReceiveDuplicateUplink(ctx, up)
return errDuplicateUplink.New()
}
trace.Log(ctx, "ns", "message is original")
Expand Down Expand Up @@ -1423,6 +1421,10 @@ func (ns *NetworkServer) HandleUplink(ctx context.Context, up *ttnpb.UplinkMessa
}
registerReceiveUplink(ctx, up)
defer func() {
if errors.Is(err, errDuplicateUplink) {
registerReceiveDuplicateUplink(ctx, up)
return
}
if err != nil {
registerDropUplink(ctx, up, err)
}
Expand Down

0 comments on commit fcac6b0

Please sign in to comment.