This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > May 2004 > XML file save clashes with XP prefetch from another process?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author XML file save clashes with XP prefetch from another process?
Andy Turner

2004-05-24, 12:15 pm


I've written an inproc server which writes to an XML file using the
MSXML.dll parser. Since it will be used by multiple clients it has to
use a system-wide mutex to control access. This works fine and
so-far-so-good. However, sometimes I get a process which gets the
mutex successfully, but then throws an exception when I call 'save' on
the XML processor, saying 0x80070020 - "The process cannot access the
file because it is in use by another process". The only way this file
ought to be being accessed is via my mutex-protected routine and
diagnostic messages prove that no other process is trying to access
the file.

After much hair-tearing and use of SysInternal's Filemon utility, I've
come to learn that the reason another process sometimes has it open is
because of the XP prefetch functionality. If one program tries to save
my XML document just as a second is starting up, then the second one
sometimes opens and then closes the XML file of its own accord, as
part of the prefetch functionality, locking out my save!!! This stops
happening if I turn prefetch off - but I'm not happy with that as a
solution.

OK, so I'm going to have to fix this by waiting and trying the save
again when I catch the exception, but it seems *bizarre* that OS-level
feature can lock an application level process out of a file - surely
this would cause problems all over the place? Surely if I try to open
a file which the prefetch functionality already has open, there should
be some hooks for it to release the file, abandon the caching and let
me open the file?

I'm worried I've got the wrong end of the stick here, since surely it
would cause all sorts of problems when people are saving files and XP
has decided to arbitrarily lock the file.


Cheers


andyt

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews