Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
daa2fdfc
Commit
daa2fdfc
authored
Aug 02, 2008
by
Hans Leidekker
Committed by
Alexandre Julliard
Aug 04, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Use getaddrinfo for thread-safe resolving if available.
parent
359cd009
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
utility.c
dlls/wininet/utility.c
+30
-3
No files found.
dlls/wininet/utility.c
View file @
daa2fdfc
...
@@ -40,6 +40,8 @@
...
@@ -40,6 +40,8 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
wininet
);
WINE_DEFAULT_DEBUG_CHANNEL
(
wininet
);
#ifndef HAVE_GETADDRINFO
/* critical section to protect non-reentrant gethostbyname() */
/* critical section to protect non-reentrant gethostbyname() */
static
CRITICAL_SECTION
cs_gethostbyname
;
static
CRITICAL_SECTION
cs_gethostbyname
;
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
...
@@ -50,6 +52,8 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
...
@@ -50,6 +52,8 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
};
};
static
CRITICAL_SECTION
cs_gethostbyname
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
CRITICAL_SECTION
cs_gethostbyname
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
#endif
#define TIME_STRING_LEN 30
#define TIME_STRING_LEN 30
time_t
ConvertTimeString
(
LPCWSTR
asctime
)
time_t
ConvertTimeString
(
LPCWSTR
asctime
)
...
@@ -142,7 +146,12 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
...
@@ -142,7 +146,12 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
WCHAR
*
found
;
WCHAR
*
found
;
char
*
name
;
char
*
name
;
int
len
,
sz
;
int
len
,
sz
;
#ifdef HAVE_GETADDRINFO
struct
addrinfo
*
res
,
hints
;
int
ret
;
#else
struct
hostent
*
phe
;
struct
hostent
*
phe
;
#endif
TRACE
(
"%s
\n
"
,
debugstr_w
(
lpszServerName
));
TRACE
(
"%s
\n
"
,
debugstr_w
(
lpszServerName
));
...
@@ -158,27 +167,45 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
...
@@ -158,27 +167,45 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
len
=
strlenW
(
lpszServerName
);
len
=
strlenW
(
lpszServerName
);
sz
=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
lpszServerName
,
len
,
NULL
,
0
,
NULL
,
NULL
);
sz
=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
lpszServerName
,
len
,
NULL
,
0
,
NULL
,
NULL
);
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sz
+
1
)
;
if
(
!
(
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sz
+
1
)))
return
FALSE
;
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
lpszServerName
,
len
,
name
,
sz
,
NULL
,
NULL
);
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
lpszServerName
,
len
,
name
,
sz
,
NULL
,
NULL
);
name
[
sz
]
=
0
;
name
[
sz
]
=
0
;
#ifdef HAVE_GETADDRINFO
memset
(
&
hints
,
0
,
sizeof
(
struct
addrinfo
)
);
hints
.
ai_family
=
AF_INET
;
ret
=
getaddrinfo
(
name
,
NULL
,
&
hints
,
&
res
);
HeapFree
(
GetProcessHeap
(),
0
,
name
);
if
(
ret
!=
0
)
{
TRACE
(
"failed to get address of %s (%s)
\n
"
,
debugstr_w
(
lpszServerName
),
gai_strerror
(
ret
));
return
FALSE
;
}
memset
(
psa
,
0
,
sizeof
(
struct
sockaddr_in
)
);
memcpy
(
&
psa
->
sin_addr
,
&
((
struct
sockaddr_in
*
)
res
->
ai_addr
)
->
sin_addr
,
sizeof
(
struct
in_addr
)
);
psa
->
sin_family
=
res
->
ai_family
;
psa
->
sin_port
=
htons
(
nServerPort
);
freeaddrinfo
(
res
);
#else
EnterCriticalSection
(
&
cs_gethostbyname
);
EnterCriticalSection
(
&
cs_gethostbyname
);
phe
=
gethostbyname
(
name
);
phe
=
gethostbyname
(
name
);
HeapFree
(
GetProcessHeap
(),
0
,
name
);
HeapFree
(
GetProcessHeap
(),
0
,
name
);
if
(
NULL
==
phe
)
if
(
NULL
==
phe
)
{
{
TRACE
(
"
Failed to get hostname: (%s)
\n
"
,
debugstr_w
(
lpszServerName
)
);
TRACE
(
"
failed to get address of %s (%d)
\n
"
,
debugstr_w
(
lpszServerName
),
h_errno
);
LeaveCriticalSection
(
&
cs_gethostbyname
);
LeaveCriticalSection
(
&
cs_gethostbyname
);
return
FALSE
;
return
FALSE
;
}
}
memset
(
psa
,
0
,
sizeof
(
struct
sockaddr_in
));
memset
(
psa
,
0
,
sizeof
(
struct
sockaddr_in
));
memcpy
((
char
*
)
&
psa
->
sin_addr
,
phe
->
h_addr
,
phe
->
h_length
);
memcpy
((
char
*
)
&
psa
->
sin_addr
,
phe
->
h_addr
,
phe
->
h_length
);
psa
->
sin_family
=
phe
->
h_addrtype
;
psa
->
sin_family
=
phe
->
h_addrtype
;
psa
->
sin_port
=
htons
(
nServerPort
);
psa
->
sin_port
=
htons
(
nServerPort
);
LeaveCriticalSection
(
&
cs_gethostbyname
);
LeaveCriticalSection
(
&
cs_gethostbyname
);
#endif
return
TRUE
;
return
TRUE
;
}
}
...
...
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