[Spice-devel] [PATCH spice-server 2/2] red-channel-client: Pass array size to red_channel_client_prepare_out_msg
Jonathon Jongsma
jjongsma at redhat.com
Tue Feb 14 17:44:51 UTC 2017
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
On Fri, 2017-02-10 at 14:02 +0000, Frediano Ziglio wrote:
> Do not make it assume vec contains IOV_MAX elements.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/red-channel-client.c | 12 +++++++-----
> server/red-channel-client.h | 4 ++--
> server/red-channel.h | 2 +-
> 3 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/server/red-channel-client.c b/server/red-channel-
> client.c
> index 5ef6fd4..68f133a 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -398,13 +398,13 @@ int red_channel_client_get_out_msg_size(void
> *opaque)
> return rcc->priv->send_data.size;
> }
>
> -void red_channel_client_prepare_out_msg(void *opaque, struct iovec
> *vec,
> - int *vec_size, int pos)
> +int red_channel_client_prepare_out_msg(void *opaque, struct iovec
> *vec,
> + int vec_size, int pos)
> {
> RedChannelClient *rcc = RED_CHANNEL_CLIENT(opaque);
>
> - *vec_size = spice_marshaller_fill_iovec(rcc->priv-
> >send_data.marshaller,
> - vec, IOV_MAX, pos);
> + return spice_marshaller_fill_iovec(rcc->priv-
> >send_data.marshaller,
> + vec, vec_size, pos);
> }
>
> void red_channel_client_on_out_block(void *opaque)
> @@ -1014,7 +1014,9 @@ static void red_peer_handle_outgoing(RedsStream
> *stream, OutgoingHandler *handle
> }
>
> for (;;) {
> - handler->cb->prepare(handler->opaque, handler->vec,
> &handler->vec_size, handler->pos);
> + handler->vec_size =
> + handler->cb->prepare(handler->opaque, handler->vec,
> G_N_ELEMENTS(handler->vec),
> + handler->pos);
> n = reds_stream_writev(stream, handler->vec, handler-
> >vec_size);
> if (n == -1) {
> switch (errno) {
> diff --git a/server/red-channel-client.h b/server/red-channel-
> client.h
> index fada609..3c9fcec 100644
> --- a/server/red-channel-client.h
> +++ b/server/red-channel-client.h
> @@ -178,8 +178,8 @@ RedChannel*
> red_channel_client_get_channel(RedChannelClient *rcc);
> void red_channel_client_on_output(void *opaque, int n);
> void red_channel_client_on_input(void *opaque, int n);
> int red_channel_client_get_out_msg_size(void *opaque);
> -void red_channel_client_prepare_out_msg(void *opaque, struct iovec
> *vec,
> - int *vec_size, int
> pos);
> +int red_channel_client_prepare_out_msg(void *opaque, struct iovec
> *vec,
> + int vec_size, int pos);
> void red_channel_client_on_out_block(void *opaque);
> void red_channel_client_on_out_msg_done(void *opaque);
>
> diff --git a/server/red-channel.h b/server/red-channel.h
> index f2866f5..a187087 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -80,7 +80,7 @@ typedef struct IncomingHandlerInterface {
> } IncomingHandlerInterface;
>
> typedef int (*get_outgoing_msg_size_proc)(void *opaque);
> -typedef void (*prepare_outgoing_proc)(void *opaque, struct iovec
> *vec, int *vec_size, int pos);
> +typedef int (*prepare_outgoing_proc)(void *opaque, struct iovec
> *vec, int vec_size, int pos);
> typedef void (*on_outgoing_error_proc)(void *opaque);
> typedef void (*on_outgoing_block_proc)(void *opaque);
> typedef void (*on_outgoing_msg_done_proc)(void *opaque);
More information about the Spice-devel
mailing list