[Spice-devel] [PATCH 04/18] server/red_worker: add free cb to EventHandler
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Feb 8 13:10:00 PST 2011
Please merge with patch 03 (keep the comment though)
On Mon, Feb 7, 2011 at 7:19 PM, Alon Levy <alevy at redhat.com> wrote:
> Added cb takes care of non zero offset embedded EventHandler, which happens
> now with the introduced CommonChannel.
> ---
> server/red_worker.c | 19 ++++++++++++++++++-
> 1 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index ba04a72..0ed46e9 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -218,9 +218,11 @@ double inline stat_byte_to_mega(uint64_t size)
>
> typedef struct EventListener EventListener;
> typedef void (*event_listener_action_proc)(EventListener *ctx, uint32_t events);
> +typedef void (*event_listener_free_proc)(EventListener *ctx);
> struct EventListener {
> uint32_t refs;
> event_listener_action_proc action;
> + event_listener_free_proc free;
> };
>
> enum {
> @@ -9319,6 +9321,13 @@ static void red_receive(RedChannel *channel)
> }
> }
>
> +static void free_common_channel_from_listener(EventListener *ctx)
> +{
> + CommonChannel* common = SPICE_CONTAINEROF(ctx, CommonChannel, listener);
> +
> + free(common);
> +}
> +
> static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_id,
> RedsStreamContext *peer, int migrate,
> event_listener_action_proc handler,
> @@ -9356,6 +9365,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
> channel->parser = spice_get_client_channel_parser(channel_id, NULL);
> common->listener.refs = 1;
> common->listener.action = handler;
> + common->listener.free = free_common_channel_from_listener;
> channel->disconnect = disconnect;
> channel->hold_item = hold_item;
> channel->release_item = release_item;
> @@ -10187,6 +10197,11 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
> }
> }
>
> +static void handle_dev_free(EventListener *ctx)
> +{
> + free(ctx);
> +}
> +
> static void red_init(RedWorker *worker, WorkerInitData *init_data)
> {
> struct epoll_event event;
> @@ -10202,6 +10217,7 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
> worker->pending = init_data->pending;
> worker->dev_listener.refs = 1;
> worker->dev_listener.action = handle_dev_input;
> + worker->dev_listener.free = handle_dev_free;
> worker->cursor_visible = TRUE;
> ASSERT(init_data->num_renderers > 0);
> worker->num_renderers = init_data->num_renderers;
> @@ -10313,7 +10329,8 @@ void *red_worker_main(void *arg)
> continue;
> }
> }
> - free(evt_listener);
> + red_printf("freeing event listener");
> + evt_listener->free(evt_listener);
> }
>
> if (worker.running) {
> --
> 1.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
--
Marc-André Lureau
More information about the Spice-devel
mailing list