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...
// TODO: use channel for errors; condense into a MultiError.
go coll.Locked()
go coll.Label()
go coll.Created()
go coll.Modified()
// TODO: use channel for errors; condense into a MultiError and switch to goroutines.
if _, err = coll.Locked(); err != nil {
return
}
if _, err = coll.Label(); err != nil {
return
}
if _, err = coll.Created(); err != nil {
return
}
if _, _, err = coll.Modified(); err != nil {
return
}

return
}

View File

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

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

View File

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

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

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

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

return