Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
1d0b5b50
Commit
1d0b5b50
authored
20 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
Curl_wait_for_resolv() could hang due to the bad timeout timer resolution and
some bad thinking on my part.
parent
b83d8104
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/hostip.c
+13
-3
13 additions, 3 deletions
lib/hostip.c
with
13 additions
and
3 deletions
lib/hostip.c
+
13
−
3
View file @
1d0b5b50
...
@@ -621,6 +621,14 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
...
@@ -621,6 +621,14 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
else
if
(
conn
->
data
->
set
.
timeout
)
else
if
(
conn
->
data
->
set
.
timeout
)
timeout
=
conn
->
data
->
set
.
timeout
;
timeout
=
conn
->
data
->
set
.
timeout
;
/* We convert the number of seconds into number of milliseconds here: */
if
(
timeout
<
2147483
)
/* maximum amount of seconds that can be multiplied with 1000 and
still fit within 31 bits */
timeout
*=
1000
;
else
timeout
=
0x7fffffff
;
/* ridiculous amount of time anyway */
/* Wait for the name resolve query to complete. */
/* Wait for the name resolve query to complete. */
while
(
1
)
{
while
(
1
)
{
int
nfds
=
0
;
int
nfds
=
0
;
...
@@ -628,9 +636,10 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
...
@@ -628,9 +636,10 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
struct
timeval
*
tvp
,
tv
,
store
;
struct
timeval
*
tvp
,
tv
,
store
;
int
count
;
int
count
;
struct
timeval
now
=
Curl_tvnow
();
struct
timeval
now
=
Curl_tvnow
();
long
timediff
;
store
.
tv_sec
=
(
int
)
timeout
;
store
.
tv_sec
=
(
int
)
timeout
/
1000
;
store
.
tv_usec
=
0
;
store
.
tv_usec
=
(
timeout
%
1000
)
*
100
0
;
FD_ZERO
(
&
read_fds
);
FD_ZERO
(
&
read_fds
);
FD_ZERO
(
&
write_fds
);
FD_ZERO
(
&
write_fds
);
...
@@ -645,7 +654,8 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
...
@@ -645,7 +654,8 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
ares_process
(
data
->
state
.
areschannel
,
&
read_fds
,
&
write_fds
);
ares_process
(
data
->
state
.
areschannel
,
&
read_fds
,
&
write_fds
);
timeout
-=
Curl_tvdiff
(
Curl_tvnow
(),
now
)
/
1000
;
/* spent time */
timediff
=
Curl_tvdiff
(
Curl_tvnow
(),
now
);
/* spent time */
timeout
-=
timediff
?
timediff
:
1
;
/* always deduct at least 1 */
if
(
timeout
<
0
)
{
if
(
timeout
<
0
)
{
/* our timeout, so we cancel the ares operation */
/* our timeout, so we cancel the ares operation */
ares_cancel
(
data
->
state
.
areschannel
);
ares_cancel
(
data
->
state
.
areschannel
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment