My Win32 app A1 (actually a collection of processes) is trying to use CreateDirectory
to create a directory D1 within parent directory P. The path to P is the value of the TMP
environment variable, which makes P a potentially busy but generally permissive place. The vast majority of the time, everything works fine, but, rarely, CreateDirectory
fails and GetLastError
then returns ERROR_ACCESS_DENIED
, the meaning of which in this context is not documented.
I wrote a test application A2 which does nothing but repeatedly create and delete a directory D2 as fast as it can within P, and I chose a goofy long name for D2 which I'm confident does not collide with any that any other program would use. Once every few minutes, there's a small fraction of a second during which A2's attempts to create D2 yield only ERROR_ACCESS_DENIED
failures.
A1 gets quite busy within P during its run. While A1 and A2 are running concurrently, the periods of ERROR_ACCESS_DENIED
failure occur somewhat more frequently, as if A1 and A2 are competing for exclusive access to P. (I am absolutely certain that A1 does not use the same name as D2. :-)
I'm somewhat inclined to take ERROR_ACCESS_DENIED
to mean "try again in a few milliseconds, and if that doesn't work after a few tries, give up", but I'm concerned that [a] in some cases it may mean something permanent that I should heed right away, and [b] because I don't really know what's happening, it may not be possible to confidently establish a reasonable amount of time to keep trying.
Anybody have experience with this? Any advice? Of particular value at this point would be clues about what causes this so I can reproduce the problem more easily.