Skip to content

Commit

Permalink
BUG:dynamicbanscore deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
lochjin authored and jcvernaleo committed Mar 9, 2020
1 parent 9e94ccb commit 96f3808
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion connmgr/dynamicbanscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type DynamicBanScore struct {
func (s *DynamicBanScore) String() string {
s.mtx.Lock()
r := fmt.Sprintf("persistent %v + transient %v at %v = %v as of now",
s.persistent, s.transient, s.lastUnix, s.Int())
s.persistent, s.transient, s.lastUnix, s.int(time.Now()))
s.mtx.Unlock()
return r
}
Expand Down
12 changes: 12 additions & 0 deletions connmgr/dynamicbanscore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ func TestDynamicBanScoreReset(t *testing.T) {
t.Errorf("Failed to reset ban score.")
}
}

// TestDynamicBanScoreString
func TestDynamicBanScoreString(t *testing.T) {
var bs DynamicBanScore
base := time.Now()

r := bs.increase(100, 50, base)
if r != 150 {
t.Errorf("Unexpected result %d after ban score increase.", r)
}
t.Log(bs.String())
}

0 comments on commit 96f3808

Please sign in to comment.