[Spice-devel] [spice-gtk PATCH v3 2/5] webdav: write all buffer to client webdav

Jeremy White jwhite at codeweavers.com
Fri Jul 17 09:51:02 PDT 2015


Hi Victor,

On 05/26/2015 08:35 AM, Victor Toso wrote:
> Client's webdav can request less data (8192) then the amount sent by
> guest's webdav. Using g_output_stream_write_all_async in order to avoid
> losing data.
> ---
>  gtk/channel-webdav.c | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/gtk/channel-webdav.c b/gtk/channel-webdav.c
> index 1d3862e..bde728e 100644
> --- a/gtk/channel-webdav.c
> +++ b/gtk/channel-webdav.c
> @@ -298,11 +298,11 @@ static void client_start_read(SpiceWebdavChannel *self, Client *client)
>  static void start_demux(SpiceWebdavChannel *self);
>  
>  static void demux_to_client_finish(SpiceWebdavChannel *self,
> -                                   Client *client, gssize size)
> +                                   Client *client, gboolean fail)
>  {
>      SpiceWebdavChannelPrivate *c = self->priv;
>  
> -    if (size <= 0) {
> +    if (fail) {
>          remove_client(self, client);
>      }
>  
> @@ -315,34 +315,37 @@ static void demux_to_client_cb(GObject *source, GAsyncResult *result, gpointer u
>      Client *client = user_data;
>      SpiceWebdavChannelPrivate *c = client->self->priv;
>      GError *error = NULL;
> -    gssize size;
> +    gboolean fail;
> +    gsize size;
>  
> -    size = g_output_stream_write_finish(G_OUTPUT_STREAM(source), result, &error);
> +    g_output_stream_write_all_finish(G_OUTPUT_STREAM(source), result, &size, &error);

This function  (and the write_all_async, below) became available in
glib-0.43, afaict.  The configure script still claims that 2.28 is good
enough.

Could you either change configure or work out a way to be 2.28 compatible?

Cheers,

Jeremy


>  
>      if (error) {
>          CHANNEL_DEBUG(client->self, "write failed: %s", error->message);
>          g_clear_error(&error);
>      }
>  
> +    fail = (size != c->demux.size);
>      g_warn_if_fail(size == c->demux.size);
> -    demux_to_client_finish(client->self, client, size);
> +    demux_to_client_finish(client->self, client, fail);
>  }
>  
>  static void demux_to_client(SpiceWebdavChannel *self,
>                              Client *client)
>  {
>      SpiceWebdavChannelPrivate *c = self->priv;
> -    gssize size = c->demux.size;
> +    gsize size = c->demux.size;
>  
> -    CHANNEL_DEBUG(self, "pushing %"G_GSSIZE_FORMAT" to client %p", size, client);
> +    CHANNEL_DEBUG(self, "pushing %"G_GSIZE_FORMAT" to client %p", size, client);
>  
>      if (size > 0) {
> -        g_output_stream_write_async(g_io_stream_get_output_stream(client->pipe),
> -                                    c->demux.buf, size, G_PRIORITY_DEFAULT,
> -                                    c->cancellable, demux_to_client_cb, client);
> +        g_output_stream_write_all_async(g_io_stream_get_output_stream(client->pipe),
> +                                        c->demux.buf, size, G_PRIORITY_DEFAULT,
> +                                        c->cancellable, demux_to_client_cb, client);
>          return;
>      } else {
> -        demux_to_client_finish(self, client, size);
> +        /* Nothing to write */
> +        demux_to_client_finish(self, client, FALSE);
>      }
>  }
>  
> 



More information about the Spice-devel mailing list