Example #1
0
mama_status
qpidBridge_close (mamaBridge bridgeImpl)
{
    mama_status      status      = MAMA_STATUS_OK;
    mamaBridgeImpl*  bridge      = (mamaBridgeImpl*) bridgeImpl;
    wthread_t        timerThread;


    /* Remove the timer heap */
    if (NULL != gQpidTimerHeap)
    {
        /* The timer heap allows us to access it's thread ID for joining */
        timerThread = timerHeapGetTid (gQpidTimerHeap);
        if (0 != destroyHeap (gQpidTimerHeap))
        {
            mama_log (MAMA_LOG_LEVEL_ERROR,
                      "qpidBridge_close(): Failed to destroy QPID timer heap.");
            status = MAMA_STATUS_PLATFORM;
        }
        /* The timer thread expects us to be responsible for terminating it */
        wthread_join    (timerThread, NULL);
    }
    gQpidTimerHeap = NULL;

    /* Destroy once queue has been emptied */
    mamaQueue_destroyTimedWait (bridge->mDefaultEventQueue,
                                QPID_SHUTDOWN_TIMEOUT);

    /* Stop and destroy the io thread */
    qpidBridgeMamaIoImpl_stop ();

    return status;
}
Example #2
0
mama_status
zmqBridge_close (mamaBridge bridgeImpl)
{
    mama_status      status      = MAMA_STATUS_OK;
    mamaBridgeImpl*  bridge      = (mamaBridgeImpl*) bridgeImpl;
    wthread_t        timerThread;

    if (NULL ==  bridgeImpl)
    {
        return MAMA_STATUS_NULL_ARG;
    }

    /* Remove the timer heap */
    if (NULL != gOmzmqTimerHeap)
    {
        /* The timer heap allows us to access it's thread ID for joining */
        timerThread = timerHeapGetTid (gOmzmqTimerHeap);
        if (0 != destroyHeap (gOmzmqTimerHeap))
        {
            mama_log (MAMA_LOG_LEVEL_ERROR,
                      "zmqBridge_close(): Failed to destroy zmq timer heap.");
            status = MAMA_STATUS_PLATFORM;
        }
        /* The timer thread expects us to be responsible for terminating it */
        wthread_join    (timerThread, NULL);
    }
    gOmzmqTimerHeap = NULL;

    /* Destroy once queue has been emptied */
    mamaQueue_destroyTimedWait (bridge->mDefaultEventQueue,
                                ZMQ_SHUTDOWN_TIMEOUT);

    /* Stop and destroy the io thread */
    zmqBridgeMamaIoImpl_stop ();

    /* Wait for zmqBridge_start to finish before destroying implementation */
    if (NULL != bridgeImpl)
    {
        free (bridgeImpl);
    }

    return status;
}