Fix data race caused by unlocked call of Dirent.descendantOf.

PiperOrigin-RevId: 224025363
Change-Id: I98864403c779832e9e1436f7d3c3f6fb2fba9904
This commit is contained in:
Nicolas Lacasse 2018-12-04 12:23:08 -08:00 committed by Shentubot
parent c3dd68cea7
commit 54dd0d0dc5
1 changed files with 4 additions and 0 deletions

View File

@ -840,6 +840,10 @@ func (d *Dirent) getDotAttrs(root *Dirent) (DentAttr, DentAttr) {
InodeID: sattr.InodeID,
}
// Hold d.mu while we call d.descendantOf.
d.mu.Lock()
defer d.mu.Unlock()
// Get '..'.
if !d.IsRoot() && d.descendantOf(root) {
// Dirent is a descendant of the root. Get its parent's attrs.