From 492d872b07d1cf834f92eafca88f0fa40d9040b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 22 Feb 2011 03:52:38 +0100 Subject: [PATCH] server: add reds_channel_dispose() 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. https://bugs.freedesktop.org/show_bug.cgi?id=34795 --- 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 1e7e318..db0de9e 100644 --- a/server/reds.c +++ b/server/reds.c @@ -1338,6 +1338,17 @@ static int sync_write(RedsStream *stream, 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; @@ -1388,6 +1399,7 @@ static int reds_send_link_ack(RedLinkInfo *link) ret &= sync_write(link->stream, channel->common_caps, 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 f18f7c9..1a4840c 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