GetEventMessage Sample

[This is preliminary documentation and subject to change.]

DWORD
APIENTRY
GetEventMessage(
    OUT ROUTING_PROTOCOL_EVENTS *pEvent,
    OUT PMESSAGE                pResult
    )
/*++
  Routine Description
      This is called by the IP Router Manager if we indicate that we
      have a message in our queue to be delivered to it (by setting the
      g_hMgrNotifyEvent)

  Arguments


  Return Value
      NO_ERROR

--*/
{
    PLIST_ENTRY pleNode;
    PMGR_MSG    pmmMsg;
    
    //
    // IMPORTANT: This can be called after the protocol is stopped
    // so we dont do ref counting for this API.
    //

    EnterCriticalSection(&g_csQueueLock);

    if(IsListEmpty(&g_leMsgQueue))
    {
        LeaveCriticalSection(&g_csQueueLock);

        return ERROR_NO_MORE_ITEMS;
    }

    pleNode = RemoveHeadList(&g_leMsgQueue);

    LeaveCriticalSection(&g_csQueueLock);
    
    pmmMsg = CONTAINING_RECORD(pleNode,
                               MGR_MSG,
                               leMsgLink);

    *pEvent  = pmmMsg->rreEvent;
    *pResult = pmmMsg->mResult;


    HeapFree(g_hPrivateHeap,
             0,
             pmmMsg);
    
    return NO_ERROR;
}