Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
a2f2d51d
Commit
a2f2d51d
authored
Mar 31, 2010
by
Rémi Denis-Courmont
Browse files
vlc_accept: accept() with close-on-exec
parent
eb1988c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/vlc_fs.h
View file @
a2f2d51d
...
...
@@ -54,6 +54,9 @@ VLC_EXPORT( int, vlc_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT
(
int
,
vlc_mkstemp
,
(
char
*
)
);
VLC_EXPORT
(
int
,
vlc_dup
,
(
int
)
);
int
vlc_socket
(
int
,
int
,
int
,
bool
nonblock
);
int
vlc_socket
(
int
,
int
,
int
,
bool
nonblock
)
LIBVLC_USED
;
struct
sockaddr
;
VLC_EXPORT
(
int
,
vlc_accept
,
(
int
,
struct
sockaddr
*
,
socklen_t
*
,
bool
)
LIBVLC_USED
);
#endif
src/libvlccore.sym
View file @
a2f2d51d
...
...
@@ -445,6 +445,7 @@ vlc_stat
vlc_unlink
vlc_rename
vlc_dup
vlc_accept
utf8_vfprintf
var_AddCallback
var_Change
...
...
src/text/filesystem.c
View file @
a2f2d51d
...
...
@@ -655,3 +655,45 @@ int vlc_socket (int pf, int type, int proto, bool nonblock)
#endif
return
fd
;
}
/**
* Accepts an inbound connection request on a listening socket.
* The new file descriptor has the close-on-exec flag set.
* @param lfd listening socket file descriptor
* @param addr pointer to the peer address or NULL [OUT]
* @param alen pointer to the length of the peer address or NULL [OUT]
* @param nonblock whether to put the new socket in non-blocking mode
* @return a new file descriptor, or -1 on error.
*/
int
vlc_accept
(
int
lfd
,
struct
sockaddr
*
addr
,
socklen_t
*
alen
,
bool
nonblock
)
{
#ifdef HAVE_ACCEPT4
int
flags
=
SOCK_CLOEXEC
;
if
(
nonblock
)
flags
|=
SOCK_NONBLOCK
;
do
{
int
fd
=
accept4
(
lfd
,
addr
,
alen
,
flags
);
if
(
fd
!=
-
1
)
return
fd
;
}
while
(
errno
==
EINTR
);
if
(
errno
!=
ENOSYS
)
return
-
1
;
#endif
#ifdef WIN32
errno
=
0
;
#endif
do
{
int
fd
=
accept
(
lfd
,
addr
,
alen
);
if
(
fd
!=
-
1
)
return
fd
;
}
while
(
errno
==
EINTR
);
return
-
1
;
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment