diff options
author | Jim Mason <jmason@ibinx.com> | 2019-09-06 19:23:01 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-09-08 20:57:25 +0000 |
commit | c2d10bd6c4dcc6af34a90a725f65461542a49a28 (patch) | |
tree | f5b9459b388c08de78ee31e5f2b01df319e30982 | |
parent | e6bd5b41935f125bf43e030dcb909c3537d33b31 (diff) |
gst_writev: respect IOV_MAX for the writev iovec array #439
-rw-r--r-- | plugins/elements/gstelements_private.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/elements/gstelements_private.c b/plugins/elements/gstelements_private.c index 47c03052e..d5368a9d5 100644 --- a/plugins/elements/gstelements_private.c +++ b/plugins/elements/gstelements_private.c @@ -121,19 +121,27 @@ struct iovec #define FDSINK_MAX_ALLOCA_SIZE (64 * 1024) /* 64k */ #define FDSINK_MAX_MALLOC_SIZE ( 8 * 1024 * 1024) /* 8M */ -/* UIO_MAXIOV is documented in writev(2), but <sys/uio.h> only - * declares it on osx/ios if defined(KERNEL) */ +/* UIO_MAXIOV is documented in writev(2) on osx/ios, but <sys/uio.h> + * only declares it if defined(KERNEL) */ #ifndef UIO_MAXIOV #define UIO_MAXIOV 512 #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 gst_writev (gint fd, const struct iovec *iov, gint iovcnt, gsize total_bytes) { gssize written; #ifdef HAVE_SYS_UIO_H - if (iovcnt <= UIO_MAXIOV) { + if (iovcnt <= IOV_MAX) { do { written = writev (fd, iov, iovcnt); } while (written < 0 && errno == EINTR); |