Re: [PATCH 2/2] Fix monitor ref counting when adding event handle

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

 



> > @@ -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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]