Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
e68d9e1a
Commit
e68d9e1a
authored
Mar 18, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Avoid using gethostbyname() which is not thread-safe
- Code simplification
parent
e9fc1b32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
33 deletions
+22
-33
modules/misc/network/ipv4.c
modules/misc/network/ipv4.c
+22
-33
No files found.
modules/misc/network/ipv4.c
View file @
e68d9e1a
...
...
@@ -103,41 +103,29 @@ vlc_module_end();
/*****************************************************************************
* BuildAddr: utility function to build a struct sockaddr_in
*****************************************************************************/
static
int
BuildAddr
(
struct
sockaddr_in
*
p_socket
,
static
int
BuildAddr
(
vlc_object_t
*
p_obj
,
struct
sockaddr_in
*
p_socket
,
const
char
*
psz_address
,
int
i_port
)
{
/* Reset struct */
memset
(
p_socket
,
0
,
sizeof
(
struct
sockaddr_in
)
);
p_socket
->
sin_family
=
AF_INET
;
/* family */
p_socket
->
sin_port
=
htons
(
(
uint16_t
)
i_port
);
if
(
!*
psz_address
)
struct
addrinfo
hints
,
*
res
;
int
i_val
;
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
hints
.
ai_family
=
AF_INET
;
hints
.
ai_socktype
=
SOCK_DGRAM
;
hints
.
ai_flags
=
AI_PASSIVE
;
msg_Dbg
(
p_obj
,
"Resolving %s:%d..."
,
psz_address
,
i_port
);
i_val
=
vlc_getaddrinfo
(
p_obj
,
psz_address
,
i_port
,
&
hints
,
&
res
);
if
(
i_val
)
{
p_socket
->
sin_addr
.
s_addr
=
INADDR_ANY
;
msg_Warn
(
p_obj
,
"%s: %s"
,
psz_address
,
vlc_gai_strerror
(
i_val
)
);
return
-
1
;
}
else
{
struct
hostent
*
p_hostent
;
/* Try to convert address directly from in_addr - this will work if
* psz_address is dotted decimal. */
#ifdef HAVE_ARPA_INET_H
if
(
!
inet_aton
(
psz_address
,
&
p_socket
->
sin_addr
)
)
#else
p_socket
->
sin_addr
.
s_addr
=
inet_addr
(
psz_address
);
if
(
p_socket
->
sin_addr
.
s_addr
==
INADDR_NONE
)
#endif
{
/* We have a fqdn, try to find its address */
if
(
(
p_hostent
=
gethostbyname
(
psz_address
))
==
NULL
)
{
return
(
-
1
);
}
/* Copy the first address of the host in the socket address */
memcpy
(
p_socket
,
res
->
ai_addr
,
sizeof
(
*
p_socket
)
);
vlc_freeaddrinfo
(
res
);
/* Copy the first address of the host in the socket address */
memcpy
(
&
p_socket
->
sin_addr
,
p_hostent
->
h_addr_list
[
0
],
p_hostent
->
h_length
);
}
}
return
(
0
);
}
...
...
@@ -243,10 +231,11 @@ static int OpenUDP( vlc_object_t * p_this )
#if defined( WIN32 ) || defined( UNDER_CE )
/* Under Win32 and for multicasting, we bind to INADDR_ANY,
* so let's call BuildAddr with "" instead of psz_bind_addr */
if
(
BuildAddr
(
&
sock
,
IN_MULTICAST
(
ntohl
(
inet_addr
(
psz_bind_addr
)
)
)
?
if
(
BuildAddr
(
p_this
,
&
sock
,
IN_MULTICAST
(
ntohl
(
inet_addr
(
psz_bind_addr
)
)
)
?
""
:
psz_bind_addr
,
i_bind_port
)
==
-
1
)
#else
if
(
BuildAddr
(
&
sock
,
psz_bind_addr
,
i_bind_port
)
==
-
1
)
if
(
BuildAddr
(
p_this
,
&
sock
,
psz_bind_addr
,
i_bind_port
)
==
-
1
)
#endif
{
msg_Dbg
(
p_this
,
"could not build local address"
);
...
...
@@ -266,7 +255,7 @@ static int OpenUDP( vlc_object_t * p_this )
/* Restore the sock struct so we can spare a few #ifdef WIN32 later on */
if
(
IN_MULTICAST
(
ntohl
(
inet_addr
(
psz_bind_addr
)
)
)
)
{
if
(
BuildAddr
(
&
sock
,
psz_bind_addr
,
i_bind_port
)
==
-
1
)
if
(
BuildAddr
(
p_this
,
&
sock
,
psz_bind_addr
,
i_bind_port
)
==
-
1
)
{
msg_Dbg
(
p_this
,
"could not build local address"
);
close
(
i_handle
);
...
...
@@ -416,7 +405,7 @@ static int OpenUDP( vlc_object_t * p_this )
if
(
*
psz_server_addr
)
{
/* Build socket for remote connection */
if
(
BuildAddr
(
&
sock
,
psz_server_addr
,
i_server_port
)
==
-
1
)
if
(
BuildAddr
(
p_this
,
&
sock
,
psz_server_addr
,
i_server_port
)
==
-
1
)
{
msg_Warn
(
p_this
,
"cannot build remote address"
);
close
(
i_handle
);
...
...
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