Open trash-boy opened 10 months ago
func (d *diskQueue) exit(deleted bool) error { d.Lock() defer d.Unlock() d.exitFlag = 1 if deleted { d.logf(INFO, "DISKQUEUE(%s): deleting", d.name) } else { d.logf(INFO, "DISKQUEUE(%s): closing", d.name) } close(d.exitChan) // ensure that ioLoop has exited <-d.exitSyncChan close(d.depthChan) if d.readFile != nil { d.readFile.Close() d.readFile = nil } if d.writeFile != nil { d.writeFile.Close() d.writeFile = nil } return nil }
d.readFile.Close() d.readFile = nil
but sync() do not d.writeFile.Sync(),may cause data loss, why not add .Sync() in exit(). for example:
func (d *diskQueue) exit(deleted bool) error { d.Lock() defer d.Unlock() d.exitFlag = 1 if deleted { d.logf(INFO, "DISKQUEUE(%s): deleting", d.name) } else { d.logf(INFO, "DISKQUEUE(%s): closing", d.name) } close(d.exitChan) // ensure that ioLoop has exited <-d.exitSyncChan close(d.depthChan) if d.readFile != nil { d.readFile.Close() d.readFile = nil } if d.writeFile != nil { d.writeFile.Close() d.writeFile.Sync() d.writeFile = nil } return nil }
感谢您的来信,我尽快回复您!
d.readFile.Close() d.readFile = nil
but sync() do not d.writeFile.Sync(),may cause data loss, why not add .Sync() in exit(). for example: