Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
d0ef6a2c
Commit
d0ef6a2c
authored
Apr 28, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix loss accounting for multiple packets.
parent
b7f39d32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
packetcache/packetcache.go
packetcache/packetcache.go
+1
-1
packetcache/packetcache_test.go
packetcache/packetcache_test.go
+13
-11
No files found.
packetcache/packetcache.go
View file @
d0ef6a2c
...
@@ -355,7 +355,7 @@ func (cache *Cache) Expect(n int) {
...
@@ -355,7 +355,7 @@ func (cache *Cache) Expect(n int) {
cache
.
mu
.
Lock
()
cache
.
mu
.
Lock
()
defer
cache
.
mu
.
Unlock
()
defer
cache
.
mu
.
Unlock
()
cache
.
expected
+=
uint32
(
n
)
cache
.
expected
+=
uint32
(
n
)
cache
.
lost
++
cache
.
lost
+=
uint32
(
n
)
}
}
// get retrieves a packet from a slice of entries.
// get retrieves a packet from a slice of entries.
...
...
packetcache/packetcache_test.go
View file @
d0ef6a2c
...
@@ -512,14 +512,14 @@ func TestCacheStatsFull(t *testing.T) {
...
@@ -512,14 +512,14 @@ func TestCacheStatsFull(t *testing.T) {
func
TestCacheStatsDrop
(
t
*
testing
.
T
)
{
func
TestCacheStatsDrop
(
t
*
testing
.
T
)
{
cache
:=
New
(
16
)
cache
:=
New
(
16
)
for
i
:=
0
;
i
<
32
;
i
++
{
for
i
:=
0
;
i
<
32
;
i
++
{
if
i
!=
8
{
if
i
!=
8
&&
i
!=
10
{
cache
.
Store
(
uint16
(
i
),
0
,
false
,
false
,
[]
byte
{
uint8
(
i
)})
cache
.
Store
(
uint16
(
i
),
0
,
false
,
false
,
[]
byte
{
uint8
(
i
)})
}
}
}
}
expected
,
lost
,
totalLost
,
eseqno
:=
cache
.
GetStats
(
false
)
expected
,
lost
,
totalLost
,
eseqno
:=
cache
.
GetStats
(
false
)
if
expected
!=
32
||
if
expected
!=
32
||
lost
!=
1
||
lost
!=
2
||
totalLost
!=
1
||
totalLost
!=
2
||
eseqno
!=
31
{
eseqno
!=
31
{
t
.
Errorf
(
"Expected 32, 1, 1, 31, got %v, %v, %v, %v"
,
t
.
Errorf
(
"Expected 32, 1, 1, 31, got %v, %v, %v, %v"
,
expected
,
lost
,
totalLost
,
eseqno
)
expected
,
lost
,
totalLost
,
eseqno
)
...
@@ -529,17 +529,18 @@ func TestCacheStatsDrop(t *testing.T) {
...
@@ -529,17 +529,18 @@ func TestCacheStatsDrop(t *testing.T) {
func
TestCacheStatsUnordered
(
t
*
testing
.
T
)
{
func
TestCacheStatsUnordered
(
t
*
testing
.
T
)
{
cache
:=
New
(
16
)
cache
:=
New
(
16
)
for
i
:=
0
;
i
<
32
;
i
++
{
for
i
:=
0
;
i
<
32
;
i
++
{
if
i
!=
8
{
if
i
!=
8
&&
i
!=
10
{
cache
.
Store
(
uint16
(
i
),
0
,
false
,
false
,
[]
byte
{
uint8
(
i
)})
cache
.
Store
(
uint16
(
i
),
0
,
false
,
false
,
[]
byte
{
uint8
(
i
)})
}
}
}
}
cache
.
Store
(
uint16
(
8
),
0
,
false
,
false
,
[]
byte
{
8
})
cache
.
Store
(
uint16
(
8
),
0
,
false
,
false
,
[]
byte
{
8
})
cache
.
Store
(
uint16
(
10
),
0
,
false
,
false
,
[]
byte
{
10
})
expected
,
lost
,
totalLost
,
eseqno
:=
cache
.
GetStats
(
false
)
expected
,
lost
,
totalLost
,
eseqno
:=
cache
.
GetStats
(
false
)
if
expected
!=
32
||
if
expected
!=
32
||
lost
!=
0
||
lost
!=
0
||
totalLost
!=
0
||
totalLost
!=
0
||
eseqno
!=
31
{
eseqno
!=
31
{
t
.
Errorf
(
"Expected 32,
1, 1
, 31, got %v, %v, %v, %v"
,
t
.
Errorf
(
"Expected 32,
0, 0
, 31, got %v, %v, %v, %v"
,
expected
,
lost
,
totalLost
,
eseqno
)
expected
,
lost
,
totalLost
,
eseqno
)
}
}
}
}
...
@@ -547,18 +548,19 @@ func TestCacheStatsUnordered(t *testing.T) {
...
@@ -547,18 +548,19 @@ func TestCacheStatsUnordered(t *testing.T) {
func
TestCacheStatsNack
(
t
*
testing
.
T
)
{
func
TestCacheStatsNack
(
t
*
testing
.
T
)
{
cache
:=
New
(
16
)
cache
:=
New
(
16
)
for
i
:=
0
;
i
<
32
;
i
++
{
for
i
:=
0
;
i
<
32
;
i
++
{
if
i
!=
8
{
if
i
!=
8
&&
i
!=
10
{
cache
.
Store
(
uint16
(
i
),
0
,
false
,
false
,
[]
byte
{
uint8
(
i
)})
cache
.
Store
(
uint16
(
i
),
0
,
false
,
false
,
[]
byte
{
uint8
(
i
)})
}
}
}
}
cache
.
Expect
(
1
)
cache
.
Expect
(
2
)
cache
.
Store
(
uint16
(
8
),
0
,
false
,
false
,
[]
byte
{
8
})
cache
.
Store
(
uint16
(
8
),
0
,
false
,
false
,
[]
byte
{
8
})
cache
.
Store
(
uint16
(
10
),
0
,
false
,
false
,
[]
byte
{
10
})
expected
,
lost
,
totalLost
,
eseqno
:=
cache
.
GetStats
(
false
)
expected
,
lost
,
totalLost
,
eseqno
:=
cache
.
GetStats
(
false
)
if
expected
!=
3
3
||
if
expected
!=
3
4
||
lost
!=
1
||
lost
!=
2
||
totalLost
!=
1
||
totalLost
!=
2
||
eseqno
!=
31
{
eseqno
!=
31
{
t
.
Errorf
(
"Expected 3
3, 1, 1
, 31, got %v, %v, %v, %v"
,
t
.
Errorf
(
"Expected 3
4, 2, 2
, 31, got %v, %v, %v, %v"
,
expected
,
lost
,
totalLost
,
eseqno
)
expected
,
lost
,
totalLost
,
eseqno
)
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment