qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 3/5] throttle: support read-only and write-only


From: Alberto Garcia
Subject: Re: [PATCH 3/5] throttle: support read-only and write-only
Date: Mon, 26 Jun 2023 21:38:23 +0000

On Sun 25 Jun 2023 04:56:29 PM +08, zhenwei pi wrote:
>  void throttle_timers_attach_aio_context(ThrottleTimers *tt,
>                                          AioContext *new_context)
>  {
> -    tt->timers[THROTTLE_TIMER_READ] =
> -        aio_timer_new(new_context, tt->clock_type, SCALE_NS,
> -                      tt->timer_cb[THROTTLE_TIMER_READ], tt->timer_opaque);
> -    tt->timers[THROTTLE_TIMER_WRITE] =
> -        aio_timer_new(new_context, tt->clock_type, SCALE_NS,
> -                      tt->timer_cb[THROTTLE_TIMER_WRITE], tt->timer_opaque);
> +    if (tt->timer_cb[THROTTLE_TIMER_READ]) {
> +        tt->timers[THROTTLE_TIMER_READ] =
> +            aio_timer_new(new_context, tt->clock_type, SCALE_NS,
> +                          tt->timer_cb[THROTTLE_TIMER_READ], 
> tt->timer_opaque);
> +    }
> +
> +    if (tt->timer_cb[THROTTLE_TIMER_WRITE]) {
> +        tt->timers[THROTTLE_TIMER_WRITE] =
> +            aio_timer_new(new_context, tt->clock_type, SCALE_NS,
> +                          tt->timer_cb[THROTTLE_TIMER_WRITE], 
> tt->timer_opaque);
> +    }
>  }

If now any of the timers can be NULL, don't you want to add additional
checks / assertions to (at least) throttle_schedule_timer() ?

Berto



reply via email to

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