[libvirt] [PATCH 2/2] Fix monitor ref counting when adding event handle
Jiri Denemark
jdenemar at redhat.com
Wed May 12 13:45:24 UTC 2010
> > @@ -648,11 +656,12 @@ qemuMonitorOpen(virDomainObjPtr vm,
> > VIR_EVENT_HANDLE_ERROR |
> > VIR_EVENT_HANDLE_READABLE,
> > qemuMonitorIO,
> > - mon, NULL)) < 0) {
> > + mon, qemuMonitorUnwatch)) < 0) {
> > qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > _("unable to register monitor events"));
> > goto cleanup;
> > }
> > + qemuMonitorRef(mon);
> >
> > VIR_DEBUG("New mon %p fd =%d watch=%d", mon, mon->fd, mon->watch);
> > qemuMonitorUnlock(mon);
>
> I was wondering if we should instead qemuMonitorRef() before calling
> virEventAddHandle(), but as long as we are in the function there is no
> risk I think so that's fine,
Yeah, the monitor is locked all the time so it doesn't really matter. And if
called qemuMonitorRef() before virEventAddHandle(), we would have to unref the
monitor in case of failure. That is, this version is one line shorter :-)
Jirka
More information about the libvir-list
mailing list