Completion Port and IRP Cancellation

I have a helper program that does inverted call and posts the requests to a third program.

The first thing my helper program does is start the my inverted call system.
After this the driver will have a number of IRP_MJ_DEVICE_CONTROL Irps queued in a cancel safe queue.
The helper program has a reader thread waiting for an inverted call request from each IRP.

The program also creates worker threads that are fed jobs from a queue.
I implemented this queue with a completion port

m_hCPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, NumberOfWorkerThreads);

I add to the queue

bResult = PostQueuedCompletionStatus(m_hCPort, 0, 0, (LPOVERLAPPED)pMyContext);

I remove from the queue

bResult = GetQueuedCompletionStatus(m_hCPort, &UnusedBytes, &UnusedKey, (LPOVERLAPPED)&pMyContext, INFINITE);

This works the early house keeping tasks go through then the problem
windbg on the next door machine shows that the waiting IRPs are cancelled.
Why is this happening? How do I prevent it?

My development box is Windows 7 64 bit. The helper program is 32 bit.

I tried creating a null file and associating the CreateIoCompletion Port with it but that made no difference.

Did the thread that posted the IRPs exit?

On Fri, 16 May 2014 09:29:04 -0400 (EDT), xxxxx@broadcom.com wrote:

Did the thread that posted the IRPs exit?

You are correct. I had come to the same conclusion. My service is failing without any indication why. That closed the driver handle and the IRPs were cancelled.

I led myself astray. The service is designed to shut down gracefully if all the IRPs are shut down. I wrongly assumed the driver was causing the shutdown which is not the case.

Sorry to have asked a silly question.