Win32 internals question: is the kernel assumed to increment the reference count of a HANDLE during overlapped I/O, such that the "correct" time to CloseHandle is after all I/O is _issued_ rather than completed? Or is it not incremented, so the CloseHandle must be deferred?
I was wondering which one Windows implemented. I will probably just end up testing experimentally and see what the deal is, but it can be hard to know if the behavior differs on different Windows platforms.
-
-
ah, I see (that's really the only interesting interpretation of your question, now that I think about it). I suspect there is an internal ref, but I haven't run into this before.
-
It's Friday and I got curious, so I spelunked in the source, and at least on Win8+, it looks like the file handle is ref'd at the start of the I/O and deref'd after the I/O completes (either successfully or failed). Seems safe to CloseHandle right after issuing IO
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.