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
236bacec
Commit
236bacec
authored
May 26, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
access_out_file: block SIGPIPE while writing to a pipe
parent
9457a9cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
modules/access_output/Makefile.am
modules/access_output/Makefile.am
+1
-0
modules/access_output/file.c
modules/access_output/file.c
+57
-1
No files found.
modules/access_output/Makefile.am
View file @
236bacec
...
...
@@ -2,6 +2,7 @@ access_outdir = $(pluginsdir)/access_output
libaccess_output_dummy_plugin_la_SOURCES
=
access_output/dummy.c
libaccess_output_file_plugin_la_SOURCES
=
access_output/file.c
libaccess_output_file_plugin_la_LIBADD
=
$(LIBPTHREAD)
libaccess_output_http_plugin_la_SOURCES
=
access_output/http.c
libaccess_output_udp_plugin_la_SOURCES
=
access_output/udp.c
libaccess_output_udp_plugin_la_LIBADD
=
$(SOCKET_LIBS)
$(LIBPTHREAD)
...
...
modules/access_output/file.c
View file @
236bacec
...
...
@@ -31,6 +31,7 @@
#endif
#include <assert.h>
#include <signal.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
...
...
@@ -103,6 +104,59 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
}
#ifdef S_ISSOCK
static
ssize_t
WritePipe
(
sout_access_out_t
*
access
,
block_t
*
block
)
{
int
fd
=
(
intptr_t
)
access
->
p_sys
;
ssize_t
total
=
0
;
sigset_t
set
,
oldset
;
sigemptyset
(
&
set
);
sigaddset
(
&
set
,
SIGPIPE
);
pthread_sigmask
(
SIG_BLOCK
,
&
set
,
&
oldset
);
while
(
block
!=
NULL
)
{
if
(
block
->
i_buffer
==
0
)
{
block_t
*
next
=
block
->
p_next
;
block_Release
(
block
);
block
=
next
;
continue
;
}
/* TODO: vectorized I/O with writev() */
ssize_t
val
=
write
(
fd
,
block
->
p_buffer
,
block
->
i_buffer
);
if
(
val
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EPIPE
)
{
siginfo_t
info
;
struct
timespec
ts
=
{
0
,
0
};
while
(
sigtimedwait
(
&
set
,
&
info
,
&
ts
)
>
0
);
}
block_ChainRelease
(
block
);
msg_Err
(
access
,
"cannot write: %s"
,
vlc_strerror_c
(
errno
));
total
=
-
1
;
break
;
}
total
+=
val
;
assert
((
size_t
)
val
<=
block
->
i_buffer
);
block
->
p_buffer
+=
val
;
block
->
i_buffer
-=
val
;
}
if
(
!
sigismember
(
&
oldset
,
SIGPIPE
))
pthread_sigmask
(
SIG_SETMASK
,
&
oldset
,
NULL
);
return
total
;
}
static
ssize_t
Send
(
sout_access_out_t
*
access
,
block_t
*
block
)
{
int
fd
=
(
intptr_t
)
access
->
p_sys
;
...
...
@@ -137,6 +191,8 @@ static ssize_t Send(sout_access_out_t *access, block_t *block)
}
return
total
;
}
#else
# define WritePipe Write
#endif
/*****************************************************************************
...
...
@@ -309,7 +365,7 @@ static int Open( vlc_object_t *p_this )
#endif
else
{
p_access
->
pf_write
=
Write
;
p_access
->
pf_write
=
Write
Pipe
;
p_access
->
pf_seek
=
NoSeek
;
}
p_access
->
pf_control
=
Control
;
...
...
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