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
6997599f
Commit
6997599f
authored
Mar 13, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Account request resending in ms.
parent
787dd794
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
16 deletions
+29
-16
message.c
message.c
+1
-1
request.c
request.c
+26
-13
request.h
request.h
+2
-2
No files found.
message.c
View file @
6997599f
...
@@ -513,7 +513,7 @@ send_request_resend(const unsigned char *prefix, unsigned char plen,
...
@@ -513,7 +513,7 @@ send_request_resend(const unsigned char *prefix, unsigned char plen,
unsigned
short
seqno
,
unsigned
short
router_hash
)
unsigned
short
seqno
,
unsigned
short
router_hash
)
{
{
send_request
(
NULL
,
prefix
,
plen
,
127
,
seqno
,
router_hash
);
send_request
(
NULL
,
prefix
,
plen
,
127
,
seqno
,
router_hash
);
record_request
(
prefix
,
plen
,
seqno
,
router_hash
,
NULL
,
2
);
record_request
(
prefix
,
plen
,
seqno
,
router_hash
,
NULL
,
2
000
);
}
}
static
void
static
void
...
...
request.c
View file @
6997599f
...
@@ -82,9 +82,12 @@ record_request(const unsigned char *prefix, unsigned char plen,
...
@@ -82,9 +82,12 @@ record_request(const unsigned char *prefix, unsigned char plen,
request
->
resend
=
MIN
(
request
->
resend
,
resend
);
request
->
resend
=
MIN
(
request
->
resend
,
resend
);
else
if
(
resend
)
else
if
(
resend
)
request
->
resend
=
resend
;
request
->
resend
=
resend
;
request
->
time
=
now
.
tv_sec
;
request
->
time
=
now
;
timeval_min_sec
(
&
request_resend_time
,
if
(
request
->
resend
)
{
request
->
time
+
request
->
resend
);
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
timeval_min
(
&
request_resend_time
,
&
timeout
);
}
if
(
request
->
router_hash
==
router_hash
&&
if
(
request
->
router_hash
==
router_hash
&&
seqno_compare
(
request
->
seqno
,
seqno
)
>
0
)
{
seqno_compare
(
request
->
seqno
,
seqno
)
>
0
)
{
return
0
;
return
0
;
...
@@ -104,10 +107,13 @@ record_request(const unsigned char *prefix, unsigned char plen,
...
@@ -104,10 +107,13 @@ record_request(const unsigned char *prefix, unsigned char plen,
request
->
seqno
=
seqno
;
request
->
seqno
=
seqno
;
request
->
router_hash
=
router_hash
;
request
->
router_hash
=
router_hash
;
request
->
network
=
network
;
request
->
network
=
network
;
request
->
time
=
now
.
tv_sec
;
request
->
time
=
now
;
request
->
resend
=
resend
;
request
->
resend
=
resend
;
if
(
resend
)
if
(
request
->
resend
)
{
timeval_min_sec
(
&
request_resend_time
,
now
.
tv_sec
+
resend
);
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
timeval_min
(
&
request_resend_time
,
&
timeout
);
}
request
->
next
=
recorded_requests
;
request
->
next
=
recorded_requests
;
recorded_requests
=
request
;
recorded_requests
=
request
;
return
1
;
return
1
;
...
@@ -168,7 +174,7 @@ expire_requests()
...
@@ -168,7 +174,7 @@ expire_requests()
previous
=
NULL
;
previous
=
NULL
;
request
=
recorded_requests
;
request
=
recorded_requests
;
while
(
request
)
{
while
(
request
)
{
if
(
request
->
time
<
now
.
tv_sec
-
REQUEST_TIMEOUT
)
{
if
(
timeval_minus_msec
(
&
now
,
&
request
->
time
)
>=
REQUEST_TIMEOUT
)
{
if
(
previous
==
NULL
)
{
if
(
previous
==
NULL
)
{
recorded_requests
=
request
->
next
;
recorded_requests
=
request
->
next
;
free
(
request
);
free
(
request
);
...
@@ -195,8 +201,11 @@ recompute_request_resend_time()
...
@@ -195,8 +201,11 @@ recompute_request_resend_time()
request
=
recorded_requests
;
request
=
recorded_requests
;
while
(
request
)
{
while
(
request
)
{
if
(
request
->
resend
)
if
(
request
->
resend
)
{
timeval_min_sec
(
&
resend
,
request
->
time
+
request
->
resend
);
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
timeval_min
(
&
request_resend_time
,
&
timeout
);
}
request
=
request
->
next
;
request
=
request
->
next
;
}
}
...
@@ -210,10 +219,14 @@ resend_requests()
...
@@ -210,10 +219,14 @@ resend_requests()
request
=
recorded_requests
;
request
=
recorded_requests
;
while
(
request
)
{
while
(
request
)
{
if
(
request
->
resend
&&
now
.
tv_sec
>=
request
->
time
+
request
->
resend
)
{
if
(
request
->
resend
)
{
struct
timeval
timeout
;
timeval_plus_msec
(
&
timeout
,
&
request
->
time
,
request
->
resend
);
if
(
timeval_compare
(
&
now
,
&
timeout
)
>=
0
)
{
send_request
(
NULL
,
request
->
prefix
,
request
->
plen
,
127
,
send_request
(
NULL
,
request
->
prefix
,
request
->
plen
,
127
,
request
->
seqno
,
request
->
router_hash
);
request
->
seqno
,
request
->
router_hash
);
request
->
resend
=
2
*
request
->
resend
;
request
->
resend
*=
2
;
}
}
}
request
=
request
->
next
;
request
=
request
->
next
;
}
}
...
...
request.h
View file @
6997599f
...
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
...
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
*/
*/
#define REQUEST_TIMEOUT 12
8
#define REQUEST_TIMEOUT 12
5000
struct
request
{
struct
request
{
unsigned
char
prefix
[
16
];
unsigned
char
prefix
[
16
];
...
@@ -28,7 +28,7 @@ struct request {
...
@@ -28,7 +28,7 @@ struct request {
unsigned
short
seqno
;
unsigned
short
seqno
;
unsigned
short
router_hash
;
unsigned
short
router_hash
;
struct
network
*
network
;
struct
network
*
network
;
int
time
;
struct
timeval
time
;
int
resend
;
int
resend
;
struct
request
*
next
;
struct
request
*
next
;
};
};
...
...
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