Skip to content

Commit

Permalink
do not drain if db is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 committed Dec 27, 2024
1 parent 5cf44ed commit 4ef89f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion chotki.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type Chotki struct {
src uint64
clock rdx.Clock

lock sync.Mutex
lock sync.RWMutex
db *pebble.DB
net *protocol.Net
dir string
Expand Down Expand Up @@ -661,6 +661,11 @@ func (cho *Chotki) drain(ctx context.Context, recs protocol.Records) (err error)
}

func (cho *Chotki) Drain(ctx context.Context, recs protocol.Records) (err error) {
cho.lock.RLock()
defer cho.lock.RUnlock()
if cho.db == nil {
return ErrClosed
}
EventsBatchSize.Observe(float64(len(recs)))
return cho.drain(ctx, recs)
}
Expand Down

0 comments on commit 4ef89f6

Please sign in to comment.