Skip to content

Commit

Permalink
meta: fix overwritten attr after timeout (#3766)
Browse files Browse the repository at this point in the history
  • Loading branch information
davies authored and SandyXSD committed Aug 23, 2023
1 parent 9219ccd commit 9b536f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/meta/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,15 @@ func (m *baseMeta) GetAttr(ctx Context, inode Ino, attr *Attr) syscall.Errno {
defer m.timeit(time.Now())
var err syscall.Errno
if inode == RootInode {
// doGetAttr could overwrite the `attr` after timeout
var a Attr
e := utils.WithTimeout(func() error {
err = m.en.doGetAttr(ctx, inode, attr)
err = m.en.doGetAttr(ctx, inode, &a)
return nil
}, time.Millisecond*300)
if e != nil || err != 0 {
if e == nil && err == 0 {
*attr = a
} else {
err = 0
attr.Typ = TypeDirectory
attr.Mode = 0777
Expand Down

0 comments on commit 9b536f2

Please sign in to comment.