qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/2] qemu-timer: make qemu_timer_mod_ns() and


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe
Date: Thu, 29 Aug 2013 17:37:29 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Aug 29, 2013 at 12:00:12PM +0200, Paolo Bonzini wrote:
> Il 27/08/2013 10:23, Stefan Hajnoczi ha scritto:
> >  /* modify the current timer so that it will be fired when current_time
> >     >= expire_time. The corresponding callback will be called. */
> >  void timer_mod_ns(QEMUTimer *ts, int64_t expire_time)
> >  {
> > +    QEMUTimerList *timer_list = ts->timer_list;
> >      QEMUTimer **pt, *t;
> >  
> >      timer_del(ts);
> >  
> >      /* add the timer in the sorted list */
> > -    pt = &ts->timer_list->active_timers;
> > +    qemu_mutex_lock(&timer_list->active_timers_lock);
> > +    pt = &timer_list->active_timers;
> 
> I think deletion and modification of the list should happen without
> releasing the lock in the middle.

Thanks for explaining the race between two timer_mod_ns() calls to me on
IRC.  I have sent a new revision of this series with your fixes included.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]