A customer was doing some testing and wanted to know if there was a way to force a call to CreateFile
to hang, so that they can test their program’s hang detection and recovery code.
You can ceate these scenarios with careful use of opportunistic locks (also known as oplocks). The sample program I wrote some time ago can be used, for example, to cause a CreateFile
call requesting write access to hang until the oplock is released.
To cause a CreateFile
call requesting read access to hang until the oplock is released, use OPLOCK_LEVEL_CACHE_WRITE
; this means that the oplock owner is caching writes, so nobody can read from the file until the cached writes are flushed out.
0 comments