From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcaPH-0007K7-DU for qemu-devel@nongnu.org; Thu, 17 Sep 2015 10:43:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcaPG-0004Ir-GL for qemu-devel@nongnu.org; Thu, 17 Sep 2015 10:43:27 -0400 Received: from mail-ob0-x236.google.com ([2607:f8b0:4003:c01::236]:35483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcaPG-0004Il-CX for qemu-devel@nongnu.org; Thu, 17 Sep 2015 10:43:26 -0400 Received: by obbzf10 with SMTP id zf10so14837256obb.2 for ; Thu, 17 Sep 2015 07:43:25 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87mvwmjokc.fsf@blackfin.pond.sub.org> References: <1441192183-4812-1-git-send-email-marcandre.lureau@redhat.com> <1441192183-4812-4-git-send-email-marcandre.lureau@redhat.com> <87mvwmjokc.fsf@blackfin.pond.sub.org> Date: Thu, 17 Sep 2015 16:43:25 +0200 Message-ID: From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] monitor: remove old entries from event hash table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: "amit.shah" , lersek@redhat.com, QEMU On Wed, Sep 16, 2015 at 6:50 PM, Markus Armbruster wrot= e: > 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 =3D 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 =3D 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 --=20 Marc-Andr=C3=A9 Lureau