Cancel-safe queue startio sample question

I don’t understand why the following from the startio CSQ sample is not
a race:

VOID CsampInitiateIo(IN PDEVICE_OBJECT DeviceObject)
// note no locks grabbed here
irp = devExtension->CurrentIrp;

This seems to me that two threads, the queuing thread from CsampRead()
and the Dpc thread started from a timer, could both complete devExtension-


Seems like the read of devExtension->CurrentIrp needs to be protected
with the same lock as CsampInsertIrp() (architecturally messy, as it’s
not a CSQ callback), or else use an interlocked exchange with 0 when
reading it.

Am I missing something?

Joe Black

Concerned about your privacy? Follow this link to get
FREE encrypted email:

Free, ultra-private instant messaging with Hush Messenger

Promote security and make money with the Hushmail Affiliate Program: