[Spice-devel] [PATCH v2 4/6] server/dispatcher: add dispatcher_register_async_callback

Yonit Halperin yhalperi at redhat.com
Mon Nov 7 23:31:57 PST 2011


Hi,
renames requests bellow
On 11/07/2011 01:44 PM, Alon Levy wrote:
> ---
>   server/dispatcher.c |    9 +++++++++
>   server/dispatcher.h |   15 +++++++++++++++
>   2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/server/dispatcher.c b/server/dispatcher.c
> index b54580e..7e9eb3a 100644
> --- a/server/dispatcher.c
> +++ b/server/dispatcher.c
> @@ -111,6 +111,8 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
>               red_printf("error writing ack for message %d\n", type);
>               /* TODO: close socketpair? */
>           }
> +    } else if (msg->ack == DISPATCHER_ASYNC&&  dispatcher->handle_async) {
> +        dispatcher->handle_async(dispatcher->opaque, type, (void *)payload);
>       }
>       return 1;
>   }
> @@ -159,6 +161,13 @@ unlock:
>       pthread_mutex_unlock(&dispatcher->lock);
>   }
>
> +void dispatcher_register_async_callback(Dispatcher *dispatcher,
> +                                        dispatcher_handle_async handler)
> +{
> +    assert(dispatcher->handle_async == NULL);
> +    dispatcher->handle_async = handler;
> +}
> +
s/handle_async/handle_async_done & s/async_callback/async_done_callback 
(to avoid confusion with handling the async request)
>   void dispatcher_register_handler(Dispatcher *dispatcher, uint32_t message_type,
>                                    dispatcher_handle_message handler, size_t size,
>                                    int ack)
> diff --git a/server/dispatcher.h b/server/dispatcher.h
> index 95b6bfc..b85d639 100644
> --- a/server/dispatcher.h
> +++ b/server/dispatcher.h
> @@ -8,6 +8,11 @@ typedef struct Dispatcher Dispatcher;
>   typedef void (*dispatcher_handle_message)(void *opaque,
>                                             void *payload);
>
> +typedef void (*dispatcher_handle_async)(void *opaque,
> +                                        uint32_t message_type,
> +                                        void *payload);
> +
> +
s/handle_async/handle_async_done
>   typedef struct DispatcherMessage {
>       size_t size;
>       int ack;
> @@ -26,6 +31,7 @@ struct Dispatcher {
>       void *payload; /* allocated as max of message sizes */
>       size_t payload_size; /* used to track realloc calls */
>       void *opaque;
> +    dispatcher_handle_async handle_async;
s/handle_async/handle_async_done
>   };
>
>   /*
> @@ -69,6 +75,15 @@ void dispatcher_register_handler(Dispatcher *dispatcher, uint32_t message_type,
>                                    int ack);
>
>   /*
> + * dispatcher_register_async_callback
> + * @dispatcher:     dispatcher
> + * @handler:        callback on the receiver side called *after* the
> + *                  message callback in case ack == DISPATCHER_ASYNC.
> + */
> +void dispatcher_register_async_callback(Dispatcher *dispatcher,
> +                                        dispatcher_handle_async handler);
> +
> +/*
>    *  dispatcher_handle_recv_read
>    *  @dispatcher: Dispatcher instance
>    */



More information about the Spice-devel mailing list