From 08cc068ead7b8e678cdb119b38ada5261d5cc3ea Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Thu, 16 Aug 2012 11:59:14 -0400 Subject: [PATCH] Allow xcb_send_request with >MAX_IOV iovecs This allows an application to do a scatter/gather operation on a large image buffer to avoid the extra memcpy. Use autoconf to use UIO_MAXIOV where IOV_MAX is not available (and the POSIX minimum of 16 where neither are available). Reviewed-by: Uli Schlachter Signed-off-by: Peter Harris --- configure.ac | 7 +++++++ src/xcb_conn.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d6b9531..3f44b53 100644 --- a/configure.ac +++ b/configure.ac @@ -117,6 +117,13 @@ dnl check for support for Solaris Trusted Extensions AC_CHECK_HEADERS([tsol/label.h]) AC_CHECK_FUNCS([is_system_labeled]) +dnl check for IOV_MAX, and fall back to UIO_MAXIOV on BSDish systems +AC_CHECK_DECL([IOV_MAX], [], + [AC_CHECK_DECL([UIO_MAXIOV], [AC_DEFINE([IOV_MAX], [UIO_MAXIOV])], + [AC_DEFINE([IOV_MAX], [16], [Define if not provided by ])], + [[#include ]])], + [[#include ]]) + xcbincludedir='${includedir}/xcb' AC_SUBST(xcbincludedir) diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 7979491..e01d566 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "xcb.h" #include "xcbint.h" @@ -209,7 +210,11 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count) i++; } #else - n = writev(c->fd, *vector, *count); + n = *count; + if (n > IOV_MAX) + n = IOV_MAX; + + n = writev(c->fd, *vector, n); if(n < 0 && errno == EAGAIN) return 1; #endif /* _WIN32 */ -- 2.7.4