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
483ff1ca
Commit
483ff1ca
authored
15 years ago
by
Yang Tse
Browse files
Options
Downloads
Patches
Plain Diff
Constantine Sapuntzakis threaded resolver enhancements
parent
c054b8bf
No related branches found
No related tags found
No related merge requests found
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
lib/hostares.c
+3
-2
3 additions, 2 deletions
lib/hostares.c
lib/hostip.h
+6
-3
6 additions, 3 deletions
lib/hostip.h
lib/hostip4.c
+48
-18
48 additions, 18 deletions
lib/hostip4.c
lib/hostip6.c
+3
-3
3 additions, 3 deletions
lib/hostip6.c
lib/hostthre.c
+224
-405
224 additions, 405 deletions
lib/hostthre.c
with
284 additions
and
431 deletions
lib/hostares.c
+
3
−
2
View file @
483ff1ca
...
...
@@ -350,7 +350,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
#ifdef ENABLE_IPV6
/* CURLRES_IPV6 */
struct
in6_addr
in6
;
#endif
/* CURLRES_IPV6 */
*
waitp
=
FALSE
;
*
waitp
=
0
;
/* default to synchronous response */
/* First check if this is an IPv4 address string */
if
(
Curl_inet_pton
(
AF_INET
,
hostname
,
&
in
)
>
0
)
{
...
...
@@ -396,7 +397,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
ares_gethostbyname
(
data
->
state
.
areschannel
,
hostname
,
family
,
(
ares_host_callback
)
ares_query_completed_cb
,
conn
);
*
waitp
=
TRUE
;
/*
please wait for the
response */
*
waitp
=
1
;
/*
expect asynchronous
response */
}
return
NULL
;
/* no struct yet */
}
...
...
This diff is collapsed.
Click to expand it.
lib/hostip.h
+
6
−
3
View file @
483ff1ca
#ifndef
_
_HOSTIP_H
#define
_
_HOSTIP_H
#ifndef
HEADER_CURL
_HOSTIP_H
#define
HEADER_CURL
_HOSTIP_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
...
...
@@ -165,6 +165,9 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
int
line
,
const
char
*
source
);
#endif
/* IPv4 threadsafe resolve function used for synch and asynch builds */
Curl_addrinfo
*
Curl_ipv4_resolve_r
(
const
char
*
hostname
,
int
port
);
/*
* Curl_addrinfo_callback() is used when we build with any asynch specialty.
* Handles end of async request processing. Inserts ai into hostcache when
...
...
@@ -214,4 +217,4 @@ void Curl_destroy_thread_data(struct Curl_async *async);
extern
sigjmp_buf
curl_jmpenv
;
#endif
#endif
#endif
/* HEADER_CURL_HOSTIP_H */
This diff is collapsed.
Click to expand it.
lib/hostip4.c
+
48
−
18
View file @
483ff1ca
...
...
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 200
9
, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 20
1
0, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
...
...
@@ -87,8 +87,7 @@ bool Curl_ipvalid(struct SessionHandle *data)
return
TRUE
;
/* OK, proceed */
}
#ifdef CURLRES_SYNCH
/* the functions below are for synchronous resolves */
#ifdef CURLRES_SYNCH
/*
* Curl_getaddrinfo() - the ipv4 synchronous version.
*
...
...
@@ -109,6 +108,33 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
const
char
*
hostname
,
int
port
,
int
*
waitp
)
{
Curl_addrinfo
*
ai
=
NULL
;
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(
void
)
conn
;
#endif
*
waitp
=
0
;
/* synchronous response only */
ai
=
Curl_ipv4_resolve_r
(
hostname
,
port
);
if
(
!
ai
)
infof
(
conn
->
data
,
"Curl_ipv4_resolve_r failed for %s
\n
"
,
hostname
);
return
ai
;
}
#endif
/* CURLRES_SYNCH */
#endif
/* CURLRES_IPV4 */
/*
* Curl_ipv4_resolve_r() - ipv4 threadsafe resolver function.
*
* This is used for both synchronous and asynchronous resolver builds,
* implying that only threadsafe code and function calls may be used.
*
*/
Curl_addrinfo
*
Curl_ipv4_resolve_r
(
const
char
*
hostname
,
int
port
)
{
#if defined(HAVE_GETHOSTBYNAME_R_3)
int
res
;
...
...
@@ -118,17 +144,28 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
struct
in_addr
in
;
struct
hostent
*
buf
=
NULL
;
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(
void
)
conn
;
#endif
*
waitp
=
0
;
/* don't wait, we act synchronously */
if
(
Curl_inet_pton
(
AF_INET
,
hostname
,
&
in
)
>
0
)
/* This is a dotted IP address 123.123.123.123-style */
return
Curl_ip2addr
(
AF_INET
,
&
in
,
hostname
,
port
);
#if defined(HAVE_GETHOSTBYNAME_R)
#if defined(HAVE_GETADDRINFO_THREADSAFE)
else
{
struct
addrinfo
hints
;
char
sbuf
[
NI_MAXSERV
];
char
*
sbufptr
=
NULL
;
int
error
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
PF_INET
;
hints
.
ai_socktype
=
SOCK_STREAM
;
if
(
port
)
{
snprintf
(
sbuf
,
sizeof
(
sbuf
),
"%d"
,
port
);
sbufptr
=
sbuf
;
}
hints
.
ai_flags
=
AI_CANONNAME
;
error
=
Curl_getaddrinfo_ex
(
hostname
,
sbufptr
,
&
hints
,
&
ai
);
#elif defined(HAVE_GETHOSTBYNAME_R)
/*
* gethostbyname_r() is the preferred resolve function for many platforms.
* Since there are three different versions of it, the following code is
...
...
@@ -260,8 +297,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
}
else
#endif
/* HAVE_GETHOSTBYNAME_R_3 */
{
infof
(
conn
->
data
,
"gethostbyname_r(2) failed for %s
\n
"
,
hostname
);
{
h
=
NULL
;
/* set return code to NULL */
free
(
buf
);
}
...
...
@@ -276,8 +312,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
#else
h
=
gethostbyname
(
hostname
);
#endif
if
(
!
h
)
infof
(
conn
->
data
,
"gethostbyname(2) failed for %s
\n
"
,
hostname
);
#endif
/*HAVE_GETHOSTBYNAME_R */
}
...
...
@@ -290,7 +324,3 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
return
ai
;
}
#endif
/* CURLRES_SYNCH */
#endif
/* CURLRES_IPV4 */
This diff is collapsed.
Click to expand it.
lib/hostip6.c
+
3
−
3
View file @
483ff1ca
...
...
@@ -126,7 +126,7 @@ bool Curl_ipvalid(struct SessionHandle *data)
return
TRUE
;
}
#if
!defined(USE_THREADING_GETADDRINFO) && !
defined(CURLRES_
ARES
)
#if defined(CURLRES_
SYNCH
)
#ifdef DEBUG_ADDRINFO
static
void
dump_addrinfo
(
struct
connectdata
*
conn
,
const
Curl_addrinfo
*
ai
)
...
...
@@ -170,7 +170,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
int
pf
;
struct
SessionHandle
*
data
=
conn
->
data
;
*
waitp
=
0
;
/*
don't wait, we have the
response
now
*/
*
waitp
=
0
;
/*
synchronous
response
only
*/
/*
* Check if a limited name resolve has been requested.
...
...
@@ -234,6 +234,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
return
res
;
}
#endif
/*
!USE_THREADING_GETADDRINFO && !
CURLRES_
ARES
*/
#endif
/* CURLRES_
SYNCH
*/
#endif
/* CURLRES_IPV6 */
This diff is collapsed.
Click to expand it.
lib/hostthre.c
+
224
−
405
View file @
483ff1ca
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