fixing some race conditions

This commit is contained in:
brent s. 2021-12-13 04:33:43 -05:00
parent 851cc327e5
commit 6dba963608
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
3 changed files with 43 additions and 15 deletions

View File

@ -30,11 +30,19 @@ func NewCollection(service *Service, path dbus.ObjectPath) (coll *Collection, er
} }


// Populate the struct fields... // Populate the struct fields...
// TODO: use channel for errors; condense into a MultiError. // TODO: use channel for errors; condense into a MultiError and switch to goroutines.
go coll.Locked() if _, err = coll.Locked(); err != nil {
go coll.Label() return
go coll.Created() }
go coll.Modified() if _, err = coll.Label(); err != nil {
return
}
if _, err = coll.Created(); err != nil {
return
}
if _, _, err = coll.Modified(); err != nil {
return
}


return return
} }

View File

@ -34,14 +34,28 @@ func NewItem(collection *Collection, path dbus.ObjectPath) (item *Item, err erro
item.collection = collection item.collection = collection


// Populate the struct fields... // Populate the struct fields...
// TODO: use channel for errors; condense into a MultiError. // TODO: use channel for errors; condense into a MultiError and switch to goroutines.
go item.GetSecret(collection.service.Session) if _, err = item.GetSecret(collection.service.Session); err != nil {
go item.Locked() return
go item.Attributes() }
go item.Label() if _, err = item.Locked(); err != nil {
go item.Type() return
go item.Created() }
go item.Modified() if _, err = item.Attributes(); err != nil {
return
}
if _, err = item.Label(); err != nil {
return
}
if _, err = item.Type(); err != nil {
return
}
if _, err = item.Created(); err != nil {
return
}
if _, _, err = item.Modified(); err != nil {
return
}


return return
} }

View File

@ -269,8 +269,11 @@ func (s *Service) Lock(objects ...LockableObject) (err error) {
} }
} }


// TODO: use channels and goroutines here.
for _, o := range objects { for _, o := range objects {
go o.Locked() if _, err = o.Locked(); err != nil {
return
}
} }


return return
@ -491,8 +494,11 @@ func (s *Service) Unlock(objects ...LockableObject) (err error) {
} }
} }


// TODO: use channels and goroutines here.
for _, o := range objects { for _, o := range objects {
go o.Locked() if _, err = o.Locked(); err != nil {
return
}
} }


return return