[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Moving alarm_timer assignment before atexit()
From: |
Laszlo Ersek |
Subject: |
Re: [Qemu-devel] [PATCH] Moving alarm_timer assignment before atexit() |
Date: |
Wed, 07 Aug 2013 08:39:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130621 Thunderbird/17.0.7 |
On 08/07/13 01:29, Amos Kong wrote:
> We register exit clean function by atexit(),
> but alarm_timer is NULL here. If exit is caused
> between atexit() and alarm_timer assignment,
> real timer can't be cleaned.
That's correct in general, but I don't see how it could happen in the
code being patched. pthread_atfork() won't call exit().
Thanks,
Laszlo
> So move alarm_timer
> assignment before atexit().
>
> Signed-off-by: Amos Kong <address@hidden>
> ---
> qemu-timer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qemu-timer.c b/qemu-timer.c
> index b2d95e2..9490105 100644
> --- a/qemu-timer.c
> +++ b/qemu-timer.c
> @@ -767,11 +767,11 @@ int init_timer_alarm(void)
> goto fail;
> }
>
> + alarm_timer = t;
> atexit(quit_timers);
> #ifdef CONFIG_POSIX
> pthread_atfork(NULL, NULL, reinit_timers);
> #endif
> - alarm_timer = t;
> return 0;
>
> fail:
>