예제 #1
0
mama_status avisTransportBridge_stop(avisTransportBridge* transportBridge)
{
    CHECK_TRANSPORT(transportBridge); 

    if (0 == wInterlocked_read (&transportBridge->mDispatching))
    {
        mama_log (MAMA_LOG_LEVEL_WARN, "avisTransportBridge_stop(): "
                                       "Avis already stopped");
        log_avis_error (MAMA_LOG_LEVEL_WARN, transportBridge->mAvis);
        return MAMA_STATUS_OK;
    }

    wInterlocked_set (0, &transportBridge->mDispatching);

    /* Dispatch a dummy notification to get the event polling to iterate
     * another loop and examine the mDispatching state */
    elvin_invoke (transportBridge->mAvis, &closeNotification, transportBridge);

    while (-1 == wsem_wait(&transportBridge->mAvisDispatchSem)) 
    {
        if (errno != EINTR) return MAMA_STATUS_SYSTEM_ERROR;
    }

    wthread_join (transportBridge->mThreadId, NULL);

    return MAMA_STATUS_OK;
}      
예제 #2
0
파일: bridge.c 프로젝트: OpenMAMA/OpenMAMA
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;
}
예제 #3
0
파일: queue.c 프로젝트: OpenMAMA/OpenMAMA
mama_status
mamaDispatcher_destroy (mamaDispatcher dispatcher)
{
    mamaDispatcherImpl* impl = (mamaDispatcherImpl*)dispatcher;

    if (!impl)
        return MAMA_STATUS_NULL_ARG;

    /* Set dispatching atomic so dispatcher thread is ready to exit */
    wInterlocked_set(0, &impl->mIsDispatching);

    if (impl->mQueue)
    {
        mamaQueue_stopDispatch (impl->mQueue);
    }

    /* Wait for the thread to return. */
    wthread_join (impl->mThread, NULL);
    wInterlocked_destroy (&impl->mIsDispatching);

    /* Destroy the thread handle. */
    wthread_destroy(impl->mThread);

    impl->mQueue->mDispatcher = NULL;
    impl->mThread = 0; 
    free (impl);
    return MAMA_STATUS_OK;
}
예제 #4
0
void
mamaTimeZone_cleanUp ()
{
    if (sThreadStarted)
    {
        sThreadStarted = 0;
        wsem_post (&sTzSem);
        wthread_join (sThread, NULL);
        wsem_destroy (&sTzSem);
    }
}
예제 #5
0
// Stop the UPAConsumer thread, which will also shut down RSSL
void UPAConsumer::JoinThread(wthread_t thread)
{
   if (0 != statsLogger_)
   {      
      statsLogger_->Stop();
   }

   t42log_info("stopping UPAConsumer thread\n");
   runThread_ = false;

   if (0 != thread)
   {
      // And wait for the thread to exit
      wthread_join(thread, NULL);
      wthread_destroy(thread);
   }
}
예제 #6
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;
}
예제 #7
0
mama_status
mamaDispatcher_destroy (mamaDispatcher dispatcher)
{
    mamaDispatcherImpl* impl = (mamaDispatcherImpl*)dispatcher;

    if (!impl)
        return MAMA_STATUS_NULL_ARG;

    if( impl->mQueue && impl->mIsDispatching )
    {
        impl->mIsDispatching = 0;
        mamaQueue_stopDispatch (impl->mQueue);
    }

    impl->mDestroy = 1;

    /* Wait for the thread to return. */
    wthread_join (impl->mThread, NULL);

    impl->mQueue->mDispatcher = NULL;
    free (impl);
    return MAMA_STATUS_OK;
}