[Spice-devel,01/11] worker: fix timer queue creation

Submitted by Frediano Ziglio on Oct. 27, 2015, 7:19 p.m.

Details

Message ID 1445973555-10337-2-git-send-email-fziglio@redhat.com
State New
Headers show
Series "Backported some patches from refactory branches (27th Oct)" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Oct. 27, 2015, 7:19 p.m.
Timer queue is attached to current thread when created so it must be
created from the proper thread.
After worker initialization was moved to main thread the queue was
created in the wrong thread causing program to fail saying that
the queue is NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/red_worker.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/red_worker.c b/server/red_worker.c
index ce2f9e2..965a14d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -11671,10 +11671,6 @@  RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
     spice_warn_if(init_info.n_surfaces > NUM_SURFACES);
     worker->n_surfaces = init_info.n_surfaces;
 
-    if (!spice_timer_queue_create()) {
-        spice_error("failed to create timer queue");
-    }
-
     red_init_quic(worker);
     red_init_lz(worker);
     red_init_jpeg(worker);
@@ -11702,6 +11698,10 @@  SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
     spice_assert(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW &&
            MAX_PIPE_SIZE > NARROW_CLIENT_ACK_WINDOW); //ensure wakeup by ack message
 
+    if (!spice_timer_queue_create()) {
+        spice_error("failed to create timer queue");
+    }
+
     if (pthread_getcpuclockid(pthread_self(), &worker->clockid)) {
         spice_warning("getcpuclockid failed");
     }

Comments

On 10/27/2015 09:19 PM, Frediano Ziglio wrote:
> Timer queue is attached to current thread when created so it must be
> created from the proper thread.
> After worker initialization was moved to main thread the queue was
> created in the wrong thread causing program to fail saying that
> the queue is NULL.

Hi Frediano,

I would replace in the log message "was moved" to "is moved in a 
following patch"

Ack.

Uri.

>
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>   server/red_worker.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index ce2f9e2..965a14d 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -11671,10 +11671,6 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
>       spice_warn_if(init_info.n_surfaces > NUM_SURFACES);
>       worker->n_surfaces = init_info.n_surfaces;
>
> -    if (!spice_timer_queue_create()) {
> -        spice_error("failed to create timer queue");
> -    }
> -
>       red_init_quic(worker);
>       red_init_lz(worker);
>       red_init_jpeg(worker);
> @@ -11702,6 +11698,10 @@ SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
>       spice_assert(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW &&
>              MAX_PIPE_SIZE > NARROW_CLIENT_ACK_WINDOW); //ensure wakeup by ack message
>
> +    if (!spice_timer_queue_create()) {
> +        spice_error("failed to create timer queue");
> +    }
> +
>       if (pthread_getcpuclockid(pthread_self(), &worker->clockid)) {
>           spice_warning("getcpuclockid failed");
>       }
>