Re: [spice-gtk PATCH v2 2/5] webdav: write all buffer to client webdav

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 19, 2015 at 04:34:34PM +0200, 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 | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/gtk/channel-webdav.c b/gtk/channel-webdav.c
> index 1d3862e..9f1ee2b 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);
>  
>      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);

Not a big problem but I forgot to change G_GSSIZE_FORMAT to
G_GSIZE_FORMAT. Will do.

>  
>      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);
>      }
>  }
>  
> -- 
> 2.4.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]