Filter Manager: bug in ctx sample or in docs?

Using IFS kit build 3790.1433…

The documentation for FltSetStreamContext says:

“After calling FltSetStreamContext, the caller must call FltReleaseContext
to decrement the reference count on NewContext, even if the call to
FltSetStreamContext was unsuccessful.”

This implies that FltSetStreamContext references the context even if it
does not use it to replace an existing context.

In the ctx sample, in context.c, function CtxFindOrCreateStreamContext,
when this situation occurs, the context is released only once. However,
according to the documentation, it should be referenced twice at this
point: once by FltAllocateContext, and once by FltSetStreamContext.

Which is correct?

Thanks,

  • Dan.

Actually both are correct.

What the documentation is saying is that you should release the stream
context always whether it failed or succeeded. If it failed releasing
it will cause it to be deleted which is what you want to do in the case
that the attach failed because a context already existed.

This is how this works. When you allocate a context a reference is
added (1). When you set the context a reference is added (residual
count (2)). If the set fails you deref (removing count from allocate),
the count goes to zero and the context is freed. If the set succeeds
you deref (removing count from allocate) but since you still have the
residual count (from the set) the context is not freed. The residual
count is removed when a context is deleted; either explicitly via a
FltDeleteXxxContext or when the object it is attached to is torn down.
The context is then freed when the ref count goes to zero.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
Sent: Friday, March 04, 2005 4:04 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager: bug in ctx sample or in docs?

Using IFS kit build 3790.1433…

The documentation for FltSetStreamContext says:

“After calling FltSetStreamContext, the caller must call
FltReleaseContext
to decrement the reference count on NewContext, even if the call to
FltSetStreamContext was unsuccessful.”

This implies that FltSetStreamContext references the context even if it
does not use it to replace an existing context.

In the ctx sample, in context.c, function CtxFindOrCreateStreamContext,
when this situation occurs, the context is released only once. However,

according to the documentation, it should be referenced twice at this
point: once by FltAllocateContext, and once by FltSetStreamContext.

Which is correct?

Thanks,

  • Dan.

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

Thanks, Neal. Sounds like it works the way it should.

I would suggest rewording the documentation. It strongly implies that the
context is referenced by a failed FltSetXxxContext.

Ideally, I’d like to see the docs clearly indicate when a routine
references a context and under what conditions.

Thanks,

  • Dan.

At 04:01 PM 3/5/2005 -0800, you wrote:

Actually both are correct.

What the documentation is saying is that you should release the stream
context always whether it failed or succeeded. If it failed releasing
it will cause it to be deleted which is what you want to do in the case
that the attach failed because a context already existed.

This is how this works. When you allocate a context a reference is
added (1). When you set the context a reference is added (residual
count (2)). If the set fails you deref (removing count from allocate),
the count goes to zero and the context is freed. If the set succeeds
you deref (removing count from allocate) but since you still have the
residual count (from the set) the context is not freed. The residual
count is removed when a context is deleted; either explicitly via a
FltDeleteXxxContext or when the object it is attached to is torn down.
The context is then freed when the ref count goes to zero.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
Sent: Friday, March 04, 2005 4:04 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager: bug in ctx sample or in docs?

Using IFS kit build 3790.1433…

The documentation for FltSetStreamContext says:

“After calling FltSetStreamContext, the caller must call
FltReleaseContext
to decrement the reference count on NewContext, even if the call to
FltSetStreamContext was unsuccessful.”

This implies that FltSetStreamContext references the context even if it
does not use it to replace an existing context.

In the ctx sample, in context.c, function CtxFindOrCreateStreamContext,
when this situation occurs, the context is released only once. However,

according to the documentation, it should be referenced twice at this
point: once by FltAllocateContext, and once by FltSetStreamContext.

Which is correct?

Thanks,

  • Dan.

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


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