ProtocolUnbindAdapter with NDIS_STATUS_PENDINF hangs

All

I am returning NDIS_STATUS_PENDING from my protocol driver (NDIS 5.1, 2k3 server).
It hangs. The moment I return pending and exit from ProtocolUnbindAdapter, it hangs (Ithink) the I/O manager also.

I tried calling NdisCloseAdapter() in ProtocolUnbindAdapter(), but it returns immediatly (but asynchronously… CloseAdapterComplete() etc), so my bindingHandle immediatly (in the context of ProtocolUnbindAdapter() itself) becomes invalid.

I need to return penidng from ProtocolUnbindAdapter(), becuase I need to notify upper layer to send any remaining pkts and need to do OID’s for clearing pkt_filter, mcast_list etc also (they will always have new pkts, just becuase I am unbinding - on hibernate etc). Once upper layer is done sending those pkts, I wanted to call NdisCompleteUnbindAdapter().
So I have to unbind asynchrouslym for my stack to work.

But if I return pending the systems hangs !
Please let me know the wrong I am doing here.

thanks…

From DDK
A protocol driver **typically** calls NdisCloseAdapter from its ProtocolUnbindAdapter function.

So Do I have to call NdisCloseAdapter from ProtocolUnbindAdapter.
I did that and returned pending from ProtocolUnbindAdapter.
Nothing happens in the system (I have intimated the I/O mgr to kill a PDO that was created earlier).
but I do not see any calls going to the PDO so that it can do its part of shutdown.

Also I just resturned pending form ProtocolUnbindAdapter without callong NdisCloseAdapetr(), even that did not help…

> I am returning NDIS_STATUS_PENDING from my protocol driver (NDIS 5.1, 2k3 server).

It hangs. The moment I return pending and exit from ProtocolUnbindAdapter,
it hangs (Ithink) the I/O manager also.

Hardly surprising - ProtocolUnbindAdapter() has to return the status that NdisCloseAdapter() that it has to call does If NdisCloseAdapter() returns success (which means ProtocolCloseAdapterComplete() has been already called ) and ProtocolCloseAdapterComplete() still returns NDIS_STATUS_PENDING,NDIS gets “confused” - it has already destroyed the binding between a protocol and underlying adapter in NdisCloseAdapter() ( by the time ProtocolCloseAdapterComplete() gets called a binding has
been already destroyed ,and if NdisCloseAdapter() returns success, it means ProtocolCloseAdapterComplete() was invoked synchronously) , but ProtocolUnbindAdapter() still returns NDIS_STATUS_PENDING. What may be possibly pending if NDIS_HANDLE that you use in all NDIS calls is already invalid??? The whole thing is too confusing for NDIS…

I need to return penidng from ProtocolUnbindAdapter(), becuase…

No you don’t - once ProtocolUnbindAdapter() is called at PASSIVE_LEVEL you can always wait in it.
Do what you want to do, wait until it gets completed (in your case, all outstanding sends are complete) ,
* and then* call NdisCloseAdapter() . Don’t forget that if NdisCloseAdapter() returns success, binding has been already destroyed, so that NDIS_HANDLE that you want to use in NdisSend() calls may be already invalid by the time NdisCloseAdapter() returns. Therefore, you can call NdisCloseAdapter() only after
all operations are complete - it has to be the last call that you make with a given NDIS_HANDLE …

Anton Bassov