Re: [PATCH v2 1/4] server/dispatcher: add extra_dispatcher, hack for red_record

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

 



On Mon, 2015-08-17 at 16:34 +0100, Frediano Ziglio wrote:
> From: Alon Levy <alon@xxxxxxxxx>
> 
> Signed-off-by: Alon Levy <alon@xxxxxxxxx>
> ---
>  server/dispatcher.c | 10 ++++++++++
>  server/dispatcher.h | 12 ++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/server/dispatcher.c b/server/dispatcher.c
> index 298f5f9..655d13f 100644
> --- a/server/dispatcher.c
> +++ b/server/dispatcher.c
> @@ -135,6 +135,9 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
>          /* TODO: close socketpair? */
>          return 0;
>      }
> +    if (dispatcher->extra_handler) {
> +        dispatcher->extra_handler(dispatcher->opaque, type, (void *)payload);
> +    }
>      if (msg->handler) {
>          msg->handler(dispatcher->opaque, (void *)payload);
>      } else {
> @@ -223,6 +226,13 @@ void dispatcher_register_handler(Dispatcher *dispatcher, uint32_t message_type,
>      }
>  }
>  
> +void dispatcher_register_extra_handler(
> +                               Dispatcher *dispatcher,
> +                               dispatcher_handle_extra_message extra_handler)
> +{
> +    dispatcher->extra_handler = extra_handler;
> +}
> +
>  #ifdef DEBUG_DISPATCHER
>  static void dummy_handler(int bla)
>  {
> diff --git a/server/dispatcher.h b/server/dispatcher.h
> index 1b389bd..9b69182 100644
> --- a/server/dispatcher.h
> +++ b/server/dispatcher.h
> @@ -8,6 +8,10 @@ typedef struct Dispatcher Dispatcher;
>  typedef void (*dispatcher_handle_message)(void *opaque,
>                                            void *payload);
>  
> +typedef void (*dispatcher_handle_extra_message)(void *opaque,
> +                                                uint32_t message_type,
> +                                                void *payload);
> +

I think that this typedef could use a better name. _handle_extra_message
implies that the handler is for an extra message. But it's actually an
extra handler. Or maybe more accurately a "universal" message handler.
It handles all messages rather than a specific message type.

It could be as simple as changing the order of the words:
"dispatcher_extra_handle_message" (which sounds rather awkward, but it
isn't as misleading as the current name). Or maybe it could be something
like "dispatcher_handle_any_message".

In the same vein, perhaps _register_extra_handler() could be changed to
_register_universal_handler(). But I can live with the current name as
long as the function typedef is changed.


>  typedef void (*dispatcher_handle_async_done)(void *opaque,
>                                               uint32_t message_type,
>                                               void *payload);
> @@ -32,6 +36,7 @@ struct Dispatcher {
>      size_t payload_size; /* used to track realloc calls */
>      void *opaque;
>      dispatcher_handle_async_done handle_async_done;
> +    dispatcher_handle_extra_message extra_handler;
>  };
>  
>  /*
> @@ -85,6 +90,13 @@ void dispatcher_register_async_done_callback(
>                                      dispatcher_handle_async_done handler);
>  
>  /*
> + * Hack to allow red_record to see the message being sent so it can record
> + * it to file.
> + */
> +void dispatcher_register_extra_handler(Dispatcher *dispatcher,
> +                                       dispatcher_handle_extra_message handler);
> +
> +/*
>   *  dispatcher_handle_recv_read
>   *  @dispatcher: Dispatcher instance
>   */


_______________________________________________
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]