Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: readdir inconsistent!

by bluto (Curate)
on Jun 27, 2007 at 19:17 UTC ( #623712=note: print w/ replies, xml ) Need Help??


in reply to readdir inconsistent!

First, you probably shouldn't assume that '.' and '..' are the first two directory entries returned from readdir(). AFAIK, this isn't guaranteed, so you should just check for them individually.

Second, are you mounting the filesystem over a network? For example, if you are using NFS make sure you test it with a hard mount or, if possible, test your code directly on the NFS server. NFS (and possibly other network filesystems) has to coordinate with the client on where in a directory it is reading from. I wouldn't be surprised if it's not exact on a huge directory since I've seen similar NFS bugs in the past.

One way to see if this is a filesystem issue, rather than in your perl code, is to use the 'find' command and count the lines in the output to see if you get inconsistent results.


Comment on Re: readdir inconsistent!
Re^2: readdir inconsistent!
by LostShootingStar (Novice) on Jun 27, 2007 at 19:28 UTC
    I just tried the 'find' command suggestion, and found that the exact same thing is happening. different results each time. So i guess its not a perl issue, but if anyone has any suggestions im open too them. One thing i found is that if I run the script back to back to back, really fast, i get the same results. but if i wait a few min, or do other things on the system inbetween, the results are different. Again, im positive the directory contents are NOT changing.
      Again, im positive the directory contents are NOT changing.

      How do you back up that claim? Did you stat the '.' entry of the directories at each run? any differences?

      You might be hitting a bug of the underlying file system. What kind is it? xfs?

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://623712]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-09-15 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (146 votes), past polls