nsqio / go-diskqueue

A Go package providing a filesystem-backed FIFO queue
MIT License
467 stars 101 forks source link

an extra read after we finish reading a file #26

Closed xianxueniao150 closed 3 years ago

xianxueniao150 commented 3 years ago

in "writeOne" method ,we move foward to next file according to the following condition if d.writePos >= d.maxBytesPerFile { d.writeFileNum++ ... }

but in "readOne" method,we move foward to next file according to the following condition if d.nextReadPos > d.maxBytesPerFile { ... d.nextReadFileNum++ }

This may cause an extra read after we finish reading a file, and this read will cause an "EOF" error

mreiferson commented 3 years ago

I think you might be looking at an older version of the code? Latest master is >= https://github.com/nsqio/go-diskqueue/blob/master/diskqueue.go#L343