[Spice-devel] [PATCH 11/13] server: add reds_channel_dispose()

Alon Levy alevy at redhat.com
Thu Feb 24 12:12:14 PST 2011


On Tue, Feb 22, 2011 at 05:09:05PM +0100, Marc-André Lureau wrote:
> Try to have a common base dispose() method for channels. For now, it
> just free the caps.
> 
> Make use of it in snd_worker, and in sync_write() - sync_write() is
> going to have default caps later on.

ACK.

> ---
>  server/reds.c       |   12 ++++++++++++
>  server/reds.h       |    2 ++
>  server/snd_worker.c |    3 +--
>  3 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index c080005..d7ac6d8 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -1347,6 +1347,17 @@ static int sync_write(RedsStream *peer, const void *in_buf, size_t n)
>      return TRUE;
>  }
>  
> +void reds_channel_dispose(Channel *channel)
> +{
> +    free(channel->caps);
> +    channel->caps = NULL;
> +    channel->num_caps = 0;
> +
> +    free(channel->common_caps);
> +    channel->common_caps = NULL;
> +    channel->num_common_caps = 0;
> +}
> +
>  static int reds_send_link_ack(RedLinkInfo *link)
>  {
>      SpiceLinkHeader header;
> @@ -1397,6 +1408,7 @@ static int reds_send_link_ack(RedLinkInfo *link)
>                        channel->num_common_caps * sizeof(uint32_t));
>      ret &= sync_write(link->stream, channel->caps, channel->num_caps * sizeof(uint32_t));
>  
> +    reds_channel_dispose(&caps);
>      BIO_free(bio);
>      return ret;
>  }
> diff --git a/server/reds.h b/server/reds.h
> index 3c810e0..f0276b1 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -72,6 +72,8 @@ struct SpiceNetWireState {
>      struct TunnelWorker *worker;
>  };
>  
> +void reds_channel_dispose(Channel *channel);
> +
>  ssize_t reds_stream_read(RedsStream *s, void *buf, size_t nbyte);
>  ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t nbyte);
>  ssize_t reds_stream_writev(RedsStream *s, const struct iovec *iov, int iovcnt);
> diff --git a/server/snd_worker.c b/server/snd_worker.c
> index e412f55..242a983 100644
> --- a/server/snd_worker.c
> +++ b/server/snd_worker.c
> @@ -1236,8 +1236,7 @@ static void snd_detach_common(SndWorker *worker)
>      snd_disconnect_channel(worker->connection);
>      reds_unregister_channel(&worker->base);
>  
> -    free(worker->base.common_caps);
> -    free(worker->base.caps);
> +    reds_channel_dispose(&worker->base);
>  }
>  
>  void snd_detach_playback(SpicePlaybackInstance *sin)
> -- 
> 1.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list