fixed rare panic
This commit is contained in:
parent
4f043d228d
commit
00d87ecb5c
2 changed files with 6 additions and 4 deletions
|
|
@ -362,6 +362,10 @@ type Metadata struct {
|
||||||
func (md *Metadata) Close() (err error) {
|
func (md *Metadata) Close() (err error) {
|
||||||
md.mu.Lock()
|
md.mu.Lock()
|
||||||
defer md.mu.Unlock()
|
defer md.mu.Unlock()
|
||||||
|
return md.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (md *Metadata) close() (err error) {
|
||||||
if md.wc != nil {
|
if md.wc != nil {
|
||||||
close(md.wc)
|
close(md.wc)
|
||||||
if md.done != nil {
|
if md.done != nil {
|
||||||
|
|
@ -383,9 +387,7 @@ func (md *Metadata) Delete() error {
|
||||||
md.cmu.Lock()
|
md.cmu.Lock()
|
||||||
md.Chunks = chunk.Chunks{}
|
md.Chunks = chunk.Chunks{}
|
||||||
md.cmu.Unlock()
|
md.cmu.Unlock()
|
||||||
close(md.wc)
|
md.close()
|
||||||
md.f.Close()
|
|
||||||
md.f = nil
|
|
||||||
atomic.StoreInt64(&md.Atime, now())
|
atomic.StoreInt64(&md.Atime, now())
|
||||||
return md.fs.RemoveDst(md.name)
|
return md.fs.RemoveDst(md.name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ func (f *file) WriteAt(data []byte, pos int64) (n int, err error) {
|
||||||
w, e := c.writeAt(data[n:], woff)
|
w, e := c.writeAt(data[n:], woff)
|
||||||
n += w
|
n += w
|
||||||
if c.full() {
|
if c.full() {
|
||||||
if f.w.last.cn == cn {
|
if f.w.last != nil && f.w.last.cn == cn {
|
||||||
f.w.last = nil
|
f.w.last = nil
|
||||||
}
|
}
|
||||||
// async flush
|
// async flush
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue