On Wed, Sep 16, 2015 at 6:50 PM, Markus Armbruster <arm...@redhat.com> wrote: > I doubt you're supposed to poke into p->timer like that. >
I don't think that matters, much (it could have a helper perhaps), anyway: >> + timer_mod_ns(p->timer, then); >> +} >> + >> +static void monitor_qapi_event_id_handler(void *opaque) >> +{ >> + MonitorQAPIEventPending *p = opaque; >> + >> + monitor_qapi_event_handler(p); >> + monitor_qapi_event_id_schedule_remove(p); >> +} >> + >> static bool >> monitor_qapi_event_id_delay(MonitorQAPIEventState *evstate, QDict *data) >> { >> @@ -554,7 +593,13 @@ monitor_qapi_event_id_delay(MonitorQAPIEventState >> *evstate, QDict *data) >> g_hash_table_insert(ht, g_strdup(id), p); >> } >> >> - return monitor_qapi_event_pending_update(evstate, p, data); >> + if (monitor_qapi_event_pending_update(evstate, p, data)) { >> + p->timer->cb = monitor_qapi_event_id_handler; >> + return true; >> + } else { >> + monitor_qapi_event_id_schedule_remove(p); >> + return false; >> + } >> } >> >> /* > > Possibly cleaner than messing with timer->cb: have a single callback > that does the right thing, i.e. when the timer goes off, check whether > we have an event. If yes, send it and rearm the timer. If no, remove > the hash entry. ok, I'll have a single handler instead -- Marc-André Lureau