Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
29c0063e
Commit
29c0063e
authored
Mar 31, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generalise struct resend.
parent
ec2ace4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
31 deletions
+50
-31
babel.c
babel.c
+1
-1
resend.c
resend.c
+43
-25
resend.h
resend.h
+6
-5
No files found.
babel.c
View file @
29c0063e
...
...
@@ -647,7 +647,7 @@ main(int argc, char **argv)
if
(
now
.
tv_sec
>=
expiry_time
)
{
check_networks
();
expire_routes
();
expire_re
quests
();
expire_re
send
();
expiry_time
=
now
.
tv_sec
+
20
+
random
()
%
20
;
}
...
...
resend.c
View file @
29c0063e
...
...
@@ -75,7 +75,7 @@ find_request(const unsigned char *prefix, unsigned char plen,
int
record_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
unsigned
short
router_hash
,
struct
network
*
network
,
int
resend
)
struct
network
*
network
,
int
delay
)
{
struct
resend
*
request
;
unsigned
int
ifindex
=
network
?
network
->
ifindex
:
0
;
...
...
@@ -84,13 +84,17 @@ record_request(const unsigned char *prefix, unsigned char plen,
output_filter
(
NULL
,
prefix
,
plen
,
ifindex
)
>=
INFINITY
)
return
0
;
if
(
delay
>=
0xFFFF
)
delay
=
0xFFFF
;
request
=
find_request
(
prefix
,
plen
,
NULL
);
if
(
request
)
{
if
(
request
->
resend
&&
resend
)
request
->
resend
=
MIN
(
request
->
resend
,
resend
);
else
if
(
resend
)
request
->
resend
=
resend
;
if
(
request
->
delay
&&
delay
)
request
->
delay
=
MIN
(
request
->
delay
,
delay
);
else
if
(
delay
)
request
->
delay
=
delay
;
request
->
time
=
now
;
request
->
max
=
128
;
if
(
request
->
router_hash
==
router_hash
&&
seqno_compare
(
request
->
seqno
,
seqno
)
>
0
)
{
return
0
;
...
...
@@ -104,20 +108,21 @@ record_request(const unsigned char *prefix, unsigned char plen,
if
(
request
==
NULL
)
return
-
1
;
request
->
kind
=
RESEND_REQUEST
;
request
->
max
=
128
;
request
->
delay
=
delay
;
memcpy
(
request
->
prefix
,
prefix
,
16
);
request
->
plen
=
plen
;
request
->
seqno
=
seqno
;
request
->
router_hash
=
router_hash
;
request
->
network
=
network
;
request
->
time
=
now
;
request
->
resend
=
resend
;
request
->
next
=
to_resend
;
to_resend
=
request
;
}
if
(
request
->
resend
)
{
if
(
request
->
delay
)
{
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
delay
);
timeval_min
(
&
resend_time
,
&
timeout
);
}
return
1
;
...
...
@@ -168,28 +173,40 @@ satisfy_request(const unsigned char *prefix, unsigned char plen,
return
0
;
}
static
int
resend_expired
(
struct
resend
*
resend
)
{
switch
(
resend
->
kind
)
{
case
RESEND_REQUEST
:
return
timeval_minus_msec
(
&
now
,
&
resend
->
time
)
>=
REQUEST_TIMEOUT
;
case
RESEND_UPDATE
:
return
resend
->
max
<=
0
;
default:
abort
();
}
}
void
expire_re
quests
()
expire_re
send
()
{
struct
resend
*
reques
t
,
*
previous
;
struct
resend
*
curren
t
,
*
previous
;
int
recompute
=
0
;
previous
=
NULL
;
reques
t
=
to_resend
;
while
(
reques
t
)
{
if
(
timeval_minus_msec
(
&
now
,
&
request
->
time
)
>=
REQUEST_TIMEOUT
)
{
curren
t
=
to_resend
;
while
(
curren
t
)
{
if
(
resend_expired
(
current
)
)
{
if
(
previous
==
NULL
)
{
to_resend
=
reques
t
->
next
;
free
(
reques
t
);
reques
t
=
to_resend
;
to_resend
=
curren
t
->
next
;
free
(
curren
t
);
curren
t
=
to_resend
;
}
else
{
previous
->
next
=
reques
t
->
next
;
free
(
reques
t
);
reques
t
=
previous
->
next
;
previous
->
next
=
curren
t
->
next
;
free
(
curren
t
);
curren
t
=
previous
->
next
;
}
recompute
=
1
;
}
else
{
request
=
reques
t
->
next
;
current
=
curren
t
->
next
;
}
}
if
(
recompute
)
...
...
@@ -204,9 +221,9 @@ recompute_resend_time()
request
=
to_resend
;
while
(
request
)
{
if
(
request
->
resend
)
{
if
(
!
resend_expired
(
request
)
&&
request
->
delay
>
0
&&
request
->
max
>
0
)
{
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
delay
);
timeval_min
(
&
resend_time
,
&
timeout
);
}
request
=
request
->
next
;
...
...
@@ -222,13 +239,14 @@ do_resend()
request
=
to_resend
;
while
(
request
)
{
if
(
request
->
resend
)
{
if
(
!
resend_expired
(
request
)
&&
request
->
delay
>
0
&&
request
->
max
>
0
)
{
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
delay
);
if
(
timeval_compare
(
&
now
,
&
timeout
)
>=
0
)
{
send_request
(
NULL
,
request
->
prefix
,
request
->
plen
,
127
,
request
->
seqno
,
request
->
router_hash
);
request
->
resend
*=
2
;
request
->
delay
*=
2
;
request
->
max
--
;
}
}
request
=
request
->
next
;
...
...
resend.h
View file @
29c0063e
...
...
@@ -26,14 +26,15 @@ THE SOFTWARE.
#define RESEND_UPDATE 2
struct
resend
{
int
kind
;
unsigned
char
kind
;
unsigned
char
max
;
unsigned
short
delay
;
struct
timeval
time
;
unsigned
char
prefix
[
16
];
unsigned
char
plen
;
unsigned
short
seqno
;
unsigned
short
router_hash
;
struct
network
*
network
;
struct
timeval
time
;
int
resend
;
struct
resend
*
next
;
};
...
...
@@ -43,13 +44,13 @@ struct resend *find_request(const unsigned char *prefix, unsigned char plen,
struct
resend
**
previous_return
);
int
record_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
unsigned
short
router_hash
,
struct
network
*
net
,
int
resend
);
struct
network
*
net
,
int
delay
);
int
unsatisfied_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
unsigned
short
router_hash
);
int
satisfy_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
unsigned
short
router_hash
,
struct
network
*
net
);
void
expire_re
quests
(
void
);
void
expire_re
send
(
void
);
void
recompute_resend_time
(
void
);
void
do_resend
(
void
);
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