On Thu, Dec 01, 2016 at 12:58:45PM +0200, Abdiel Janulgue wrote:
> Fixes an issue when calling igt_spin_batch_set_timeout and then
> tearing down the spinner right away before it has the chance
> to timeout, causes the associated signal handler to linger. Make
> sure to remove the handler on the destructor as well.
> 
> Signed-off-by: Abdiel Janulgue <abdiel.janul...@linux.intel.com>
> ---
>  lib/igt_dummyload.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
> index 99515ea..b201af0 100644
> --- a/lib/igt_dummyload.c
> +++ b/lib/igt_dummyload.c
> @@ -169,9 +169,17 @@ igt_spin_batch_new(int fd, int engine, unsigned int 
> dep_handle)
>       return spin;
>  }
>  
> -static void sig_handler(int sig, siginfo_t *info, void *arg)
> +static void clear_sig_handler(int sig)
>  {
>       struct sigaction act;
> +
> +     memset(&act, 0, sizeof(act));
> +     act.sa_handler = SIG_DFL;
> +     igt_assert(sigaction(sig, &act, NULL) == 0);
> +}
> +
> +static void sig_handler(int sig, siginfo_t *info, void *arg)
> +{
>       struct igt_spin *iter;
>  
>       igt_list_for_each(iter, &spin_list, link) {
> @@ -181,9 +189,7 @@ static void sig_handler(int sig, siginfo_t *info, void 
> *arg)
>               }
>       }
>  
> -     memset(&act, 0, sizeof(act));
> -     act.sa_handler = SIG_DFL;
> -     igt_assert(sigaction(info->si_signo, &act, NULL) == 0);
> +     clear_sig_handler(info->si_signo);
>  }
>  
>  /**
> @@ -248,6 +254,7 @@ void igt_spin_batch_end(igt_spin_t *spin)
>  
>       *spin->batch = MI_BATCH_BUFFER_END;
>       __sync_synchronize();

Newline here since these are two different phases.

> +     clear_sig_handler(spin->signo);

I was also thinking about decoupling from the list of spinners here as
well. Just looked like some more work to use safe iterators and
list_del_init().

Reviewed-by: Chris Wilson <ch...@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to