[Spice-devel] [PATCH spice-server 12/28] server/red_worker: assign timer callbacks to worker_core, using spice_timer_queue

Alon Levy alevy at redhat.com
Sun Apr 14 06:24:58 PDT 2013


On Tue, Feb 26, 2013 at 01:03:58PM -0500, Yonit Halperin wrote:
> display channel - supplying timeouts interface to red_channel, in order to allow
> periodic latency monitoring (see next patch).

ACK

> ---
>  server/red_worker.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/server/red_worker.c b/server/red_worker.c
> index a390629..cb695fe 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -80,6 +80,7 @@
>  #include "dispatcher.h"
>  #include "main_channel.h"
>  #include "migration_protocol.h"
> +#include "spice_timer_queue.h"
>  
>  //#define COMPRESS_STAT
>  //#define DUMP_BITMAP
> @@ -10066,6 +10067,11 @@ static void worker_watch_remove(SpiceWatch *watch)
>  }
>  
>  SpiceCoreInterface worker_core = {
> +    .timer_add = spice_timer_queue_add,
> +    .timer_start = spice_timer_set,
> +    .timer_cancel = spice_timer_cancel,
> +    .timer_remove = spice_timer_remove,
> +
>      .watch_update_mask = worker_watch_update_mask,
>      .watch_add = worker_watch_add,
>      .watch_remove = worker_watch_remove,
> @@ -11836,6 +11842,10 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
>      spice_warn_if(init_data->n_surfaces > NUM_SURFACES);
>      worker->n_surfaces = init_data->n_surfaces;
>  
> +    if (!spice_timer_queue_create()) {
> +        spice_error("failed to create timer queue");
> +    }
> +
>      message = RED_WORKER_MESSAGE_READY;
>      write_message(worker->channel, &message);
>  }
> @@ -11869,10 +11879,14 @@ SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
>      worker->event_timeout = INF_EVENT_WAIT;
>      for (;;) {
>          int i, num_events;
> +        unsigned int timers_queue_timeout;
>  
> +        timers_queue_timeout = spice_timer_queue_get_timeout_ms();
>          worker->event_timeout = MIN(red_get_streams_timout(worker), worker->event_timeout);
> +        worker->event_timeout = MIN(timers_queue_timeout, worker->event_timeout);
>          num_events = poll(worker->poll_fds, MAX_EVENT_SOURCES, worker->event_timeout);
>          red_handle_streams_timout(worker);
> +        spice_timer_queue_cb();
>  
>          if (worker->display_channel) {
>              /* during migration, in the dest, the display channel can be initialized
> -- 
> 1.8.1
> 
> _______________________________________________
> 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