Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
d71bd09f
Commit
d71bd09f
authored
Jun 30, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: add vlc_read_i11e(v) and vlc_write_i11e(v) helpers
parent
a7596108
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
0 deletions
+102
-0
include/vlc_interrupt.h
include/vlc_interrupt.h
+6
-0
src/libvlccore.sym
src/libvlccore.sym
+4
-0
src/misc/interrupt.c
src/misc/interrupt.c
+92
-0
No files found.
include/vlc_interrupt.h
View file @
d71bd09f
...
...
@@ -28,6 +28,7 @@
# include <vlc_threads.h>
struct
pollfd
;
struct
iovec
;
/**
* @defgroup interrupt Interruptible sleep
...
...
@@ -71,6 +72,11 @@ VLC_API int vlc_sem_wait_i11e(vlc_sem_t *);
*/
VLC_API
int
vlc_poll_i11e
(
struct
pollfd
*
,
unsigned
,
int
);
VLC_API
ssize_t
vlc_readv_i11e
(
int
fd
,
struct
iovec
*
,
int
);
VLC_API
ssize_t
vlc_writev_i11e
(
int
fd
,
const
struct
iovec
*
,
int
);
VLC_API
ssize_t
vlc_read_i11e
(
int
fd
,
void
*
,
size_t
);
VLC_API
ssize_t
vlc_write_i11e
(
int
fd
,
const
void
*
,
size_t
);
/**
* @}
* @defgroup interrupt_context Interrupt context signaling and manipulation
...
...
src/libvlccore.sym
View file @
d71bd09f
...
...
@@ -540,6 +540,10 @@ vlc_iconv
vlc_iconv_close
vlc_iconv_open
vlc_poll_i11e
vlc_read_i11e
vlc_readv_i11e
vlc_write_i11e
vlc_writev_i11e
vlc_sem_wait_i11e
vlc_interrupt_create
vlc_interrupt_destroy
...
...
src/misc/interrupt.c
View file @
d71bd09f
...
...
@@ -360,6 +360,75 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
return
ret
;
}
# include <fcntl.h>
# include <sys/uio.h>
/* There are currently no ways to atomically force a non-blocking read or write
* operations. Even for sockets, the MSG_DONTWAIT flag is non-standard.
*
* So in the event that more than one thread tries to read or write on the same
* file at the same time, there is a race condition where these functions might
* block inspite of an interruption. This should never happen in practice.
*/
/**
* Wrapper for readv() that returns the EINTR error upon VLC I/O interruption.
* @warning This function ignores the non-blocking file flag.
*/
ssize_t
vlc_readv_i11e
(
int
fd
,
struct
iovec
*
iov
,
int
count
)
{
struct
pollfd
ufd
;
ufd
.
fd
=
fd
;
ufd
.
events
=
POLLIN
;
if
(
vlc_poll_i11e
(
&
ufd
,
1
,
-
1
)
<
0
)
return
-
1
;
return
readv
(
fd
,
iov
,
count
);
}
/**
* Wrapper for writev() that returns the EINTR error upon VLC I/O interruption.
*
* @note Like writev(), once some but not all bytes are written, the function
* might wait for write completion, regardless of signals and interruptions.
* @warning This function ignores the non-blocking file flag.
*/
ssize_t
vlc_writev_i11e
(
int
fd
,
const
struct
iovec
*
iov
,
int
count
)
{
struct
pollfd
ufd
;
ufd
.
fd
=
fd
;
ufd
.
events
=
POLLOUT
;
if
(
vlc_poll_i11e
(
&
ufd
,
1
,
-
1
)
<
0
)
return
-
1
;
return
writev
(
fd
,
iov
,
count
);
}
/**
* Wrapper for read() that returns the EINTR error upon VLC I/O interruption.
* @warning This function ignores the non-blocking file flag.
*/
ssize_t
vlc_read_i11e
(
int
fd
,
void
*
buf
,
size_t
count
)
{
struct
iovec
iov
=
{
buf
,
count
};
return
vlc_readv_i11e
(
fd
,
&
iov
,
1
);
}
/**
* Wrapper for write() that returns the EINTR error upon VLC I/O interruption.
*
* @note Like write(), once some but not all bytes are written, the function
* might wait for write completion, regardless of signals and interruptions.
* @warning This function ignores the non-blocking file flag.
*/
ssize_t
vlc_write_i11e
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
struct
iovec
iov
=
{
(
void
*
)
buf
,
count
};
return
writev
(
fd
,
&
iov
,
1
);
}
#else
/* _WIN32 */
static
void
CALLBACK
vlc_poll_i11e_wake_self
(
ULONG_PTR
data
)
...
...
@@ -422,4 +491,27 @@ out:
CloseHandle
(
th
);
return
ret
;
}
ssize_t
vlc_readv_i11e
(
int
fd
,
struct
iovec
*
iov
,
int
count
)
{
(
void
)
fd
;
(
void
)
iov
;
(
void
)
count
;
vlc_assert_unreachable
();
}
ssize_t
vlc_writev_i11e
(
int
fd
,
const
struct
iovec
*
iov
,
int
count
)
{
(
void
)
fd
;
(
void
)
iov
;
(
void
)
count
;
vlc_assert_unreachable
();
}
ssize_t
vlc_read_i11e
(
int
fd
,
void
*
buf
,
size_t
count
)
{
return
read
(
fd
,
buf
,
count
);
}
ssize_t
vlc_write_i11e
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
return
write
(
fd
,
buf
,
count
);
}
#endif
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