Fix theoretical race in readdir pending check.