Skip to content

Commit

Permalink
separate mutexes for commit and close
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 committed Jan 8, 2025
1 parent 3e38256 commit dac4fe5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chotki.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type Chotki struct {
clock rdx.Clock

lock sync.RWMutex
commitMutex sync.Mutex
db *pebble.DB
net *protocol.Net
dir string
Expand Down Expand Up @@ -487,8 +488,8 @@ func (cho *Chotki) Broadcast(ctx context.Context, records protocol.Records, exce

// Here new packets are timestamped and queued for save
func (cho *Chotki) CommitPacket(ctx context.Context, lit byte, ref rdx.ID, body protocol.Records) (id rdx.ID, err error) {
cho.lock.Lock()
defer cho.lock.Unlock()
cho.commitMutex.Lock()
defer cho.commitMutex.Unlock()

if cho.db == nil {
return rdx.BadId, ErrClosed
Expand Down

0 comments on commit dac4fe5

Please sign in to comment.