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
3eb3e72a
Commit
3eb3e72a
authored
Mar 31, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_socket: create socket with close-on-exec à la vlc_dup()
parent
a2c859a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
include/vlc_fs.h
include/vlc_fs.h
+1
-0
src/text/filesystem.c
src/text/filesystem.c
+43
-3
No files found.
include/vlc_fs.h
View file @
3eb3e72a
...
@@ -54,5 +54,6 @@ VLC_EXPORT( int, vlc_lstat, ( const char *filename, struct stat *buf ) );
...
@@ -54,5 +54,6 @@ VLC_EXPORT( int, vlc_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT
(
int
,
vlc_mkstemp
,
(
char
*
)
);
VLC_EXPORT
(
int
,
vlc_mkstemp
,
(
char
*
)
);
VLC_EXPORT
(
int
,
vlc_dup
,
(
int
)
);
VLC_EXPORT
(
int
,
vlc_dup
,
(
int
)
);
int
vlc_socket
(
int
,
int
,
int
,
bool
nonblock
);
#endif
#endif
src/text/filesystem.c
View file @
3eb3e72a
...
@@ -42,9 +42,6 @@
...
@@ -42,9 +42,6 @@
#ifdef HAVE_DIRENT_H
#ifdef HAVE_DIRENT_H
# include <dirent.h>
# include <dirent.h>
#endif
#endif
#ifdef UNDER_CE
# include <tchar.h>
#endif
#ifdef HAVE_SYS_STAT_H
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
# include <sys/stat.h>
#endif
#endif
...
@@ -53,11 +50,15 @@
...
@@ -53,11 +50,15 @@
#endif
#endif
#ifdef WIN32
#ifdef WIN32
# include <io.h>
# include <io.h>
# include <winsock2.h>
# ifndef UNDER_CE
# ifndef UNDER_CE
# include <direct.h>
# include <direct.h>
# else
# include <tchar.h>
# endif
# endif
#else
#else
# include <unistd.h>
# include <unistd.h>
# include <sys/socket.h>
#endif
#endif
#ifndef HAVE_LSTAT
#ifndef HAVE_LSTAT
...
@@ -615,3 +616,42 @@ int vlc_dup (int oldfd)
...
@@ -615,3 +616,42 @@ int vlc_dup (int oldfd)
#endif
#endif
return
newfd
;
return
newfd
;
}
}
/**
* Creates a socket file descriptor. The new file descriptor has the
* close-on-exec flag set.
* @param pf protocol family
* @param type socket type
* @param proto network protocol
* @param nonblock true to create a non-blocking socket
* @return a new file descriptor or -1
*/
int
vlc_socket
(
int
pf
,
int
type
,
int
proto
,
bool
nonblock
)
{
int
fd
;
#ifdef SOCK_CLOEXEC
type
|=
SOCK_CLOEXEC
;
if
(
nonblock
)
type
|=
SOCK_NONBLOCK
;
fd
=
socket
(
pf
,
type
|
SOCK_NONBLOCK
|
SOCK_CLOEXEC
,
proto
);
if
(
fd
!=
-
1
||
errno
!=
EINVAL
)
return
fd
;
type
&=
~
(
SOCK_CLOEXEC
|
SOCK_NONBLOCK
);
#endif
fd
=
socket
(
pf
,
type
,
proto
);
if
(
fd
==
-
1
)
return
-
1
;
#ifndef WIN32
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
);
if
(
nonblock
)
fcntl
(
fd
,
F_SETFL
,
fcntl
(
fd
,
F_GETFL
,
0
)
|
O_NONBLOCK
);
#else
if
(
nonblock
)
ioctlsocket
(
fd
,
FIONBIO
,
&
(
unsigned
long
){
1
});
#endif
return
fd
;
}
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