Nikolay Sivov (@nsivov) commented about dlls/mf/session.c:
if (op->command == SESSION_CMD_CLEAR_TOPOLOGIES || op->command == SESSION_CMD_CLOSE || op->command == SESSION_CMD_SHUTDOWN) continue;
/* Once a command is submitted, the callback becomes responsible
* for removal from the list and release of the ref. */
if (op->submitted)
continue;
Would it make sense to remove it from commands list right before it's submitted and use a second list for submitted commands? Maybe this will break somewhere, I don't remember all the details of how this works. If all we need is to basically ignore its presence in the list by checking this flag, maybe we could simply remove it from the list in the first place.
If we actually need this flag, I think it should be set before calling MFPutWorkItem(), and then it's more natural to check for it first in purge_pending_commands() before filtering by command types.