Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
6d16c3b1
Commit
6d16c3b1
authored
May 17, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 9.5.11.2: requests are randomized 0%-200% of value
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
c985998f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
timeout.c
timeout.c
+28
-19
No files found.
timeout.c
View file @
6d16c3b1
...
...
@@ -6,19 +6,25 @@
*/
#include <ppsi/ppsi.h>
enum
rand_type
{
RAND_NONE
,
/* Not randomized */
RAND_70_130
,
/* Should be 70% to 130% of 1 << value */
RAND_0_200
,
/* Should be 0% to 200% of 1 << value */
};
struct
timeout_config
{
char
*
name
;
int
is
rand
;
int
which_
rand
;
int
value
;
};
/* most timeouts have a static configuration. Save it here */
static
struct
timeout_config
to_configs
[
__PP_TO_ARRAY_SIZE
]
=
{
[
PP_TO_REQUEST
]
=
{
"REQUEST"
,
1
,},
[
PP_TO_SYNC_SEND
]
=
{
"SYNC_SEND"
,
1
,},
[
PP_TO_ANN_RECEIPT
]
=
{
"ANN_RECEIPT"
,
0
,},
[
PP_TO_ANN_SEND
]
=
{
"ANN_SEND"
,
1
,},
[
PP_TO_FAULTY
]
=
{
"FAULTY"
,
0
,
4000
},
[
PP_TO_REQUEST
]
=
{
"REQUEST"
,
RAND_0_200
,},
[
PP_TO_SYNC_SEND
]
=
{
"SYNC_SEND"
,
RAND_70_130
,},
[
PP_TO_ANN_RECEIPT
]
=
{
"ANN_RECEIPT"
,
RAND_NONE
,},
[
PP_TO_ANN_SEND
]
=
{
"ANN_SEND"
,
RAND_70_130
,},
[
PP_TO_FAULTY
]
=
{
"FAULTY"
,
RAND_NONE
,
4000
},
/* extension timeouts are explicitly set to a value */
};
...
...
@@ -43,12 +49,6 @@ void __pp_timeout_set(struct pp_instance *ppi, int index, int millisec)
to_configs
[
index
].
name
,
millisec
);
}
/*
* Randomize a timeout. We are required to fit between 70% and 130%
* of the value for 90% of the time, at least. But making it "almost
* exact" is bad in a big network. So randomize between 80% and 120%:
* constant part is 80% and variable is 40%.
*/
void
pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
)
{
...
...
@@ -57,11 +57,6 @@ void pp_timeout_set(struct pp_instance *ppi, int index)
int
millisec
;
int
logval
=
to_configs
[
index
].
value
;
if
(
!
to_configs
[
index
].
isrand
){
__pp_timeout_set
(
ppi
,
index
,
logval
);
/* not a logval */
return
;
}
if
(
!
seed
)
{
uint32_t
*
p
;
/* use the least 32 bits of the mac address as seed */
...
...
@@ -84,9 +79,23 @@ void pp_timeout_set(struct pp_instance *ppi, int index)
* Here below, 0 gets to 16 * 25 = 400ms, 40% of the nominal value
*/
millisec
=
(
1
<<
(
logval
+
4
))
*
25
;
/* twice 40% + a random value between 0 and 40% */
millisec
=
(
millisec
*
2
)
+
rval
%
millisec
;
switch
(
to_configs
[
index
].
which_rand
)
{
case
RAND_70_130
:
/*
* We are required to fit between 70% and 130%
* of the value for 90% of the time, at least.
* So randomize between 80% and 120%: constant
* part is 80% and variable is 40%.
*/
millisec
=
(
millisec
*
2
)
+
rval
%
millisec
;
break
;
case
RAND_0_200
:
millisec
=
rval
%
(
millisec
*
5
);
break
;
case
RAND_NONE
:
millisec
=
logval
;
/* not a log, just a constant */
}
__pp_timeout_set
(
ppi
,
index
,
millisec
);
}
...
...
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