mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-11-18 11:21:25 +00:00
Fix merge conflict upstream/resf
Signed-off-by: Mustafa Gezen <mustafa@ctrliq.com>
This commit is contained in:
parent
8ef874b5ae
commit
0a712673a7
@ -106,9 +106,11 @@ func (s *Server) importRpmKey(publicKey string) error {
|
|||||||
// WarmGPGKey warms up a specific GPG key
|
// WarmGPGKey warms up a specific GPG key
|
||||||
// This involves shelling out to GPG to import the key
|
// This involves shelling out to GPG to import the key
|
||||||
func (s *Server) WarmGPGKey(key string, armoredKey string, gpgKey *crypto.Key, db *models.Key) (*LoadedKey, error) {
|
func (s *Server) WarmGPGKey(key string, armoredKey string, gpgKey *crypto.Key, db *models.Key) (*LoadedKey, error) {
|
||||||
|
s.keyImportLock.ReadLock(key)
|
||||||
|
defer s.keyImportLock.ReadUnlock(key)
|
||||||
|
|
||||||
cachedKey := s.keys[key]
|
cachedKey := s.keys[key]
|
||||||
// This means that the key is already loaded
|
// This means that the key is already loaded
|
||||||
// We need to delete and replace it
|
|
||||||
if cachedKey != nil {
|
if cachedKey != nil {
|
||||||
return cachedKey, nil
|
return cachedKey, nil
|
||||||
}
|
}
|
||||||
|
@ -57,17 +57,45 @@ import (
|
|||||||
|
|
||||||
const TaskQueue = "keykeeper"
|
const TaskQueue = "keykeeper"
|
||||||
|
|
||||||
|
type MapStringLock struct {
|
||||||
|
*sync.RWMutex
|
||||||
|
m map[string]*sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MapStringLock) ReadLock(key string) {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
if m.m[key] == nil {
|
||||||
|
m.Lock()
|
||||||
|
m.m[key] = &sync.Mutex{}
|
||||||
|
m.Unlock()
|
||||||
|
}
|
||||||
|
m.m[key].Lock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MapStringLock) ReadUnlock(key string) {
|
||||||
|
m.RLock()
|
||||||
|
defer m.RUnlock()
|
||||||
|
if m.m[key] == nil {
|
||||||
|
m.Lock()
|
||||||
|
m.m[key] = &sync.Mutex{}
|
||||||
|
m.Unlock()
|
||||||
|
}
|
||||||
|
m.m[key].Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
keykeeperpb.UnimplementedKeykeeperServiceServer
|
keykeeperpb.UnimplementedKeykeeperServiceServer
|
||||||
|
|
||||||
log *logrus.Logger
|
log *logrus.Logger
|
||||||
db peridotdb.Access
|
db peridotdb.Access
|
||||||
storage lookaside.Storage
|
storage lookaside.Storage
|
||||||
worker worker.Worker
|
worker worker.Worker
|
||||||
temporal client.Client
|
temporal client.Client
|
||||||
stores map[string]store.Store
|
stores map[string]store.Store
|
||||||
keys map[string]*LoadedKey
|
keys map[string]*LoadedKey
|
||||||
defaultStore string
|
keyImportLock *MapStringLock
|
||||||
|
defaultStore string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(db peridotdb.Access, c client.Client) (*Server, error) {
|
func NewServer(db peridotdb.Access, c client.Client) (*Server, error) {
|
||||||
@ -82,13 +110,19 @@ func NewServer(db peridotdb.Access, c client.Client) (*Server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Server{
|
return &Server{
|
||||||
log: logrus.New(),
|
log: logrus.New(),
|
||||||
db: db,
|
db: db,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
worker: worker.New(c, TaskQueue, worker.Options{}),
|
worker: worker.New(c, TaskQueue, worker.Options{
|
||||||
temporal: c,
|
DeadlockDetectionTimeout: 15 * time.Minute,
|
||||||
stores: map[string]store.Store{"awssm": sm},
|
}),
|
||||||
keys: map[string]*LoadedKey{},
|
temporal: c,
|
||||||
|
stores: map[string]store.Store{"awssm": sm},
|
||||||
|
keys: map[string]*LoadedKey{},
|
||||||
|
keyImportLock: &MapStringLock{
|
||||||
|
RWMutex: &sync.RWMutex{},
|
||||||
|
m: map[string]*sync.Mutex{},
|
||||||
|
},
|
||||||
defaultStore: "awssm",
|
defaultStore: "awssm",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user