locked
STATUS_DEVICE_BUSY from FwpsCalloutUnregisterById RRS feed

  • Question

  • In my driver I have 3 callouts that run in sequence. #1 redirects connections, #2 adds a context to them and #3 injects data into connections based on the context and then removes it. However when there's a lot going on (a few hundred active connections in debug mode) and someone decides to unload the driver the first and probably second callouts are unregistered successfully while the third one (the one's that supposed to delete contexts after using them) often returns STATUS_DEVICE_BUSY. This happens in the DriverUnload function and there's not much I can do. I don't preserve a list of contexts whatsoever - everything runs asynchronously. It will (quite soon) stop being busy and all I need to do is wait a short bit. There will be no new connections as callouts #2 and #3 are gone. Is using KeDelayExecutionThread() in DriverUnload a good idea or is there a better way?

    Currently, for testing, I've made a loop of 50x100ms 'sleeps' - each with a DbgPrint('waiting'). I've also added a DbgPrint('remove') just before the call to remove a context. I expected to see a mix of these lines on the debugger. But instead I see a wave of 'waiting' and then (mine) debug break occurs as this is not the way I want things to end. Why are there no 'remove' lines during the waiting loop? There are plenty of 'remove'-s while the driver is working...

     


    QmQ
    Tuesday, October 11, 2011 2:13 PM

Answers

  • Yes you can call KeDelayExecutionThread() from within the DriverUnload.  This is a hack though, and the proper thing to do is create a flow table, and terminate the flows.

     

    As for your debug issue, I would likely need to see your code in order to make sense of what it is you are trying to accomplish.

     

    Hope this helps,

     


    Dusty Harper [MSFT]
    Microsoft Corporation
    ------------------------------------------------------------
    This posting is provided "AS IS", with NO warranties and confers NO rights
    ------------------------------------------------------------
    • Marked as answer by QmQ Wednesday, October 19, 2011 11:48 AM
    Tuesday, October 18, 2011 6:04 PM
    Moderator

All replies

  • Yes you can call KeDelayExecutionThread() from within the DriverUnload.  This is a hack though, and the proper thing to do is create a flow table, and terminate the flows.

     

    As for your debug issue, I would likely need to see your code in order to make sense of what it is you are trying to accomplish.

     

    Hope this helps,

     


    Dusty Harper [MSFT]
    Microsoft Corporation
    ------------------------------------------------------------
    This posting is provided "AS IS", with NO warranties and confers NO rights
    ------------------------------------------------------------
    • Marked as answer by QmQ Wednesday, October 19, 2011 11:48 AM
    Tuesday, October 18, 2011 6:04 PM
    Moderator
  • Thanks. If this is the correct way I will implement such a table and the problem will probably be solved. I will reply here if something is still not OK.


    QmQ
    • Edited by QmQ Wednesday, October 19, 2011 12:58 PM
    Wednesday, October 19, 2011 11:54 AM