[Xcb] [PATCH v3] Allow xcb_send_request with >MAX_IOV iovecs
Uli Schlachter
psychon at znc.in
Sat Sep 15 04:50:29 PDT 2012
On 16.08.2012 17:59, Peter Harris wrote:
> 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).
>
> Signed-off-by: Peter Harris <pharris at opentext.com>
What's the current state of this? The needed patched for making sure config.h
gets included first in every .c file have already landed, so this patch could go
in next.
In case it helps (although I don't have any weird boxes to test this on):
Reviewed-by: Uli Schlachter <psychon at znc.in>
> ---
> configure.ac | 7 +++++++
> src/xcb_conn.c | 7 ++++++-
> 2 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index e94e32c..d27e2fd 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -110,6 +110,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 <limits.h>])],
> + [[#include <sys/uio.h>]])],
> + [[#include <limits.h>]])
> +
> xcbincludedir='${includedir}/xcb'
> AC_SUBST(xcbincludedir)
>
> diff --git a/src/xcb_conn.c b/src/xcb_conn.c
> index 725502a..69f6580 100644
> --- a/src/xcb_conn.c
> +++ b/src/xcb_conn.c
> @@ -32,6 +32,7 @@
> #include <stdlib.h>
> #include <fcntl.h>
> #include <errno.h>
> +#include <limits.h>
>
> #include "xcb.h"
> #include "xcbint.h"
> @@ -204,7 +205,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 */
--
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?" -- A. P. J.
More information about the Xcb
mailing list