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

Re: [libvirt] PATCH: 12/28: Thread safety for UML driver



On Tue, Dec 02, 2008 at 12:05:10PM +0100, Daniel Veillard wrote:
> On Sun, Nov 30, 2008 at 11:53:17PM +0000, Daniel P. Berrange wrote:
> > This patch makes the UML driver thread safe
> 
> [...]
> > @@ -1395,21 +1485,27 @@ static int umlListDefinedDomains(virConn
> >      struct uml_driver *driver = conn->privateData;
> >      int got = 0, i;
> >  
> > +    umlDriverLock(driver);
> >      for (i = 0 ; i < driver->domains.count && got < nnames ; i++) {
> > +        virDomainObjLock(driver->domains.objs[i]);
> >          if (!virDomainIsActive(driver->domains.objs[i])) {
> >              if (!(names[got++] = strdup(driver->domains.objs[i]->def->name))) {
> >                  umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
> >                                   "%s", _("failed to allocate space for VM name string"));
> > +                virDomainObjUnlock(driver->domains.objs[i]);
> >                  goto cleanup;
> >              }
> >          }
> > +        virDomainObjUnlock(driver->domains.objs[i]);
> >      }
> > +    umlDriverUnlock(driver);
> >  
> >      return got;
> >  
> >   cleanup:
> 
>   since this is an error code path, I would rather change the label to
> error: ...

That's a good idea - we should define a standard naming for this usage

  'cleanup' to be used where error & normal conditions shared the same
            exit path of a method.

  'error' to be used where error path is completely separate from the
          normal exit path.


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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