Skip to content

Commit

Permalink
Change locking
Browse files Browse the repository at this point in the history
  • Loading branch information
pgporada committed May 15, 2024
1 parent ecf01b1 commit 66e448c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions db/memorystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (m *MemoryStore) UpdateReplacedOrder(serial *big.Int) error {
return acme.InternalErrorProblem(fmt.Sprintf("could not find an order for the given certificate: %s", err))
}

m.RLock()
defer m.RUnlock()
m.Lock()
defer m.Unlock()

originalOrder.IsReplaced = true
m.ordersByID[originalOrder.ID] = originalOrder
Expand Down Expand Up @@ -220,8 +220,8 @@ func (m *MemoryStore) GetOrderByID(id string) *core.Order {
if err != nil {
panic(err)
}
order.RLock()
defer order.RUnlock()
order.Lock()
defer order.Unlock()
order.Status = orderStatus
return order
}
Expand All @@ -239,8 +239,8 @@ func (m *MemoryStore) GetOrderByCertSerial(certID *big.Int) (*core.Order, error)
defer m.RUnlock()

for _, order := range m.ordersByID {
order.Lock()
defer order.Unlock()
order.RLock()
defer order.RUnlock()
if order.CertificateObject == nil || order.CertificateObject.Cert == nil {
continue
}
Expand All @@ -262,8 +262,8 @@ func (m *MemoryStore) GetOrdersByAccountID(accountID string) []*core.Order {
if err != nil {
panic(err)
}
order.RLock()
defer order.RUnlock()
order.Lock()
defer order.Unlock()
order.Status = orderStatus
}
return orders
Expand Down

0 comments on commit 66e448c

Please sign in to comment.