qemu-devel
[Top][All Lists]
Advanced

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

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


From: zhenwei pi
Subject: Re: Re: [PATCH 3/5] throttle: support read-only and write-only
Date: Tue, 27 Jun 2023 13:25:30 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0



On 6/27/23 05:38, Alberto Garcia wrote:
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

OK.

--
zhenwei pi



reply via email to

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