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);
+ }
}