Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion diskqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ func New(name string, dataPath string, maxBytesPerFile int64,

// Depth returns the depth of the queue
func (d *diskQueue) Depth() int64 {
return <-d.depthChan
depth, ok := <-d.depthChan
if !ok {
// ioLoop exited
depth = d.depth
}
return depth
}

// ReadChan returns the receive-only []byte channel for reading data
Expand Down Expand Up @@ -188,6 +193,8 @@ func (d *diskQueue) exit(deleted bool) error {
// ensure that ioLoop has exited
<-d.exitSyncChan

close(d.depthChan)

if d.readFile != nil {
d.readFile.Close()
d.readFile = nil
Expand Down