To finish the monologue:
It’s perfectly valid to do (VOID) CloseHandle()unless you were
attempting to close an invalid handle and attempting to catch bugs in
your own code.
Ravi
-----Original Message-----
From: Ravisankar Pudipeddi
Sent: Tuesday, November 23, 2004 10:53 PM
To: ‘Windows File Systems Devs Interest List’
Subject: RE: [ntfsd] Failing IRP_MJ_CLOSE/CLEANUP…
CloseHandle() cannot fail unless the handle is invalid i.e. the only
time CloseHandle() will return a failure status is if the handle that is
supplied is not an open handle for the process. As for drivers - they
are expected to succeed CLEANUP & CLOSE always.
Ob will destroy the handle table entry regardless of how the driver
handles cleanup - think of CloseHandle() as a destructor, or a memory
free operation. It doesn’t fail. Note that CloseHandle() does not call
CLEANUP and return the status of that: it simply decrements the handle
count. If the handle count goes to zero (there could be duplicates of
this handle, each of which bumps up the handle count), an IRP_MJ_CLEANUP
is generated - this is a side effect of the decrement handle count
operation.
Finally when the pointer count goes to zero, an IRP_MJ_CLOSE is
generated, but Ob destroys the object. So regardless of how the client
of Ob (I/O in this case) deals with their object close (i.e. handle
count goes to zero) or object destroy (pointer count goes to zero), Ob
will always destroy handles when the handle count is zero, and delete
objects when pointer count is zero.
Ravi
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jamey Kirby
Sent: Tuesday, November 23, 2004 10:01 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Failing IRP_MJ_CLOSE/CLEANUP…
Some of us have never ventured out of kernel-mode. What is CloseHandle()
anyway?
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michal Vodicka
Sent: Tuesday, November 23, 2004 8:00 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Failing IRP_MJ_CLOSE/CLEANUP…
You’re of course right and I have similar experience: most developers
ignore
CloseHandle() result. I just hope it doesn’t apply to members of this
list
I only wanted to point out that failing IRP_MJ_CLOSE can cause
unexpected problems to others.
BTW, checking “unimportant” error codes is one of side effect of using
lint which complaints about any function which return code is unused.
Good effect.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
From:
xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com
] on behalf of Tony Mason[SMTP:xxxxx@osr.com]
Reply To: Windows File Systems Devs Interest List
Sent: Wednesday, November 24, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Failing IRP_MJ_CLOSE/CLEANUP…
Oh, I certainly agree - and I write code that checks the value of
CloseHandle. However, I stand by my original observation that “in my
experience applications do not generally look for this error…”
The first time I saw this was 15 years ago when debugging the
“compact”
UNIX utility and how it worked on top of AFS with respect to
out-of-quota errors (which are reported at close time). Since then
I’ve found very few developers who check for errors on close.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michal Vodicka
Sent: Tuesday, November 23, 2004 5:38 PM
To: ntfsd redirect
Subject: RE: [ntfsd] Failing IRP_MJ_CLOSE/CLEANUP…
> ----------
> From:
xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.c
om ] on behalf of Tony Mason[SMTP:xxxxx@osr.com]
> Reply To: Windows File Systems Devs Interest List
> Sent: Tuesday, November 23, 2004 8:47 AM
> To: Windows File Systems Devs Interest List
> Subject: RE: [ntfsd] Failing IRP_MJ_CLOSE/CLEANUP…
>
> The return value from IRP_MJ_CLEANUP will be reflected in the
> CloseHandle call (for example) but in my experience applications do
not
> generally look for this error - nor is it clear what the correct
> behavior is if this call fails.
>
Paranoid developers (kernel mode forced to write an app usually
write something like VERIFY(CloseHandle(Handle)) to be notified about
possible error. An error there means something is wrong with app;
Handle value is wrong for some reason. Overwritten or closed before.
In any case the error means code should be checked. If kernel returns
failure for correct handle, it could lead to real headache. So please,
don’t do it
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com