Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
a0645402
Commit
a0645402
authored
Nov 07, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some fixes in network
parent
433ce145
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
net.c
net.c
+15
-4
queries.c
queries.c
+5
-1
No files found.
net.c
View file @
a0645402
...
...
@@ -44,15 +44,20 @@ extern struct connection_methods auth_methods;
void
fail_connection
(
struct
connection
*
c
);
#define PING_TIMEOUT 10
void
start_ping_timer
(
struct
connection
*
c
);
int
ping_alarm
(
struct
connection
*
c
)
{
if
(
verbosity
>
2
)
{
logprintf
(
"ping alarm
\n
"
);
}
if
(
get_double_time
()
-
c
->
last_receive_time
>
20
)
{
if
(
get_double_time
()
-
c
->
last_receive_time
>
20
*
PING_TIMEOUT
)
{
if
(
verbosity
)
{
logprintf
(
"fail connection: reason: ping timeout
\n
"
);
}
c
->
state
=
conn_failed
;
fail_connection
(
c
);
}
else
if
(
get_double_time
()
-
c
->
last_receive_time
>
5
&&
c
->
state
==
conn_ready
)
{
}
else
if
(
get_double_time
()
-
c
->
last_receive_time
>
5
*
PING_TIMEOUT
&&
c
->
state
==
conn_ready
)
{
int
x
[
3
];
x
[
0
]
=
CODE_ping
;
*
(
long
long
*
)(
x
+
1
)
=
lrand48
()
*
(
1ll
<<
32
)
+
lrand48
();
...
...
@@ -69,7 +74,7 @@ void stop_ping_timer (struct connection *c) {
}
void
start_ping_timer
(
struct
connection
*
c
)
{
c
->
ev
.
timeout
=
get_double_time
()
+
1
;
c
->
ev
.
timeout
=
get_double_time
()
+
PING_TIMEOUT
;
c
->
ev
.
alarm
=
(
void
*
)
ping_alarm
;
c
->
ev
.
self
=
c
;
insert_event_timer
(
&
c
->
ev
);
...
...
@@ -358,6 +363,9 @@ void try_write (struct connection *c) {
delete_connection_buffer
(
b
);
}
else
{
if
(
errno
!=
EAGAIN
&&
errno
!=
EWOULDBLOCK
)
{
if
(
verbosity
)
{
logprintf
(
"fail_connection: write_error %m
\n
"
);
}
fail_connection
(
c
);
return
;
}
else
{
...
...
@@ -459,6 +467,9 @@ void try_read (struct connection *c) {
c
->
in_tail
=
b
;
}
else
{
if
(
errno
!=
EAGAIN
&&
errno
!=
EWOULDBLOCK
)
{
if
(
verbosity
)
{
logprintf
(
"fail_connection: read_error %m
\n
"
);
}
fail_connection
(
c
);
return
;
}
else
{
...
...
@@ -512,7 +523,7 @@ void connections_poll_result (struct pollfd *fds, int max) {
}
if
(
fds
[
i
].
revents
&
(
POLLHUP
|
POLLERR
|
POLLRDHUP
))
{
if
(
verbosity
)
{
logprintf
(
"fail connection
\n
"
);
logprintf
(
"fail_connection: events_mask=0x%08x
\n
"
,
fds
[
i
].
revents
);
}
fail_connection
(
c
);
}
else
if
(
fds
[
i
].
revents
&
POLLOUT
)
{
...
...
queries.c
View file @
a0645402
...
...
@@ -56,7 +56,7 @@ long long cur_downloading_bytes;
long
long
cur_downloaded_bytes
;
void
out_peer_id
(
peer_id_t
id
);
#define QUERY_TIMEOUT
0.3
#define QUERY_TIMEOUT
6.0
#define memcmp8(a,b) memcmp ((a), (b), 8)
DEFINE_TREE
(
query
,
struct
query
*
,
memcmp8
,
0
)
;
...
...
@@ -80,6 +80,10 @@ int alarm_query (struct query *q) {
q
->
ev
.
timeout
=
get_double_time
()
+
QUERY_TIMEOUT
;
insert_event_timer
(
&
q
->
ev
);
if
(
q
->
session
->
c
->
out_bytes
>=
100000
)
{
return
0
;
}
clear_packet
();
out_int
(
CODE_msg_container
);
out_int
(
1
);
...
...
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