{"id":45391,"date":"2015-06-12T07:00:00","date_gmt":"2015-06-12T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20150612-00\/?p=45391\/"},"modified":"2019-03-13T12:16:18","modified_gmt":"2019-03-13T19:16:18","slug":"20150612-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20150612-00\/?p=45391\/","title":{"rendered":"How can I force a CreateFile call to hang, in order to test something?"},"content":{"rendered":"<p>A customer was doing some testing and wanted to know if there was a way to force a call to <code>Create&shy;File<\/code> to hang, so that they can test their program&#8217;s hang detection and recovery code. <\/p>\n<p>You can ceate these scenarios with careful use of opportunistic locks (also known as oplocks). <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2013\/04\/15\/10410965.aspx\">The sample program I wrote some time ago<\/a> can be used, for example, to cause a <code>Create&shy;File<\/code> call requesting write access to hang until the oplock is released. <\/p>\n<p>To cause a <code>Create&shy;File<\/code> call requesting read access to hang until the oplock is released, use <code>OPLOCK_LEVEL_CACHE_WRITE<\/code>; this means that the oplock owner is caching writes, so nobody can read from the file until the cached writes are flushed out. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Opportunistic locks again.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-45391","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Opportunistic locks again.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/45391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=45391"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/45391\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=45391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=45391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=45391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}