mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 13:11:06 +00:00
gst_writev: respect IOV_MAX for the writev iovec array #439
This commit is contained in:
parent
e6bd5b4193
commit
c2d10bd6c4
1 changed files with 11 additions and 3 deletions
|
@ -121,19 +121,27 @@ struct iovec
|
||||||
#define FDSINK_MAX_ALLOCA_SIZE (64 * 1024) /* 64k */
|
#define FDSINK_MAX_ALLOCA_SIZE (64 * 1024) /* 64k */
|
||||||
#define FDSINK_MAX_MALLOC_SIZE ( 8 * 1024 * 1024) /* 8M */
|
#define FDSINK_MAX_MALLOC_SIZE ( 8 * 1024 * 1024) /* 8M */
|
||||||
|
|
||||||
/* UIO_MAXIOV is documented in writev(2), but <sys/uio.h> only
|
/* UIO_MAXIOV is documented in writev(2) on osx/ios, but <sys/uio.h>
|
||||||
* declares it on osx/ios if defined(KERNEL) */
|
* only declares it if defined(KERNEL) */
|
||||||
#ifndef UIO_MAXIOV
|
#ifndef UIO_MAXIOV
|
||||||
#define UIO_MAXIOV 512
|
#define UIO_MAXIOV 512
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* POSIX writev(2) documents IOV_MAX as the max length of the iov array.
|
||||||
|
* If IOV_MAX is undefined, fall back to the legacy UIO_MAXIOV.
|
||||||
|
*/
|
||||||
|
#ifndef IOV_MAX
|
||||||
|
#define IOV_MAX UIO_MAXIOV
|
||||||
|
#endif
|
||||||
|
|
||||||
static gssize
|
static gssize
|
||||||
gst_writev (gint fd, const struct iovec *iov, gint iovcnt, gsize total_bytes)
|
gst_writev (gint fd, const struct iovec *iov, gint iovcnt, gsize total_bytes)
|
||||||
{
|
{
|
||||||
gssize written;
|
gssize written;
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UIO_H
|
#ifdef HAVE_SYS_UIO_H
|
||||||
if (iovcnt <= UIO_MAXIOV) {
|
if (iovcnt <= IOV_MAX) {
|
||||||
do {
|
do {
|
||||||
written = writev (fd, iov, iovcnt);
|
written = writev (fd, iov, iovcnt);
|
||||||
} while (written < 0 && errno == EINTR);
|
} while (written < 0 && errno == EINTR);
|
||||||
|
|
Loading…
Reference in a new issue