示例#1
0
void MAMACALLTYPE
subscriptionOnMsg  (mamaSubscription subscription,
                    mamaMsg msg,
                    void *closure,
                    void *itemClosure)
{
    pubCache* cache = (pubCache*) closure;
    switch (mamaMsgType_typeForMsg (msg))
    {
    case MAMA_MSG_TYPE_DELETE:
    case MAMA_MSG_TYPE_EXPIRE:
        mamaSubscription_destroy (subscription);
        mamaSubscription_deallocate (subscription);
        if (cache->pub)
            mamaDQPublisher_send(cache->pub, msg);
        cache->sub = NULL;
        return;
    default:
        break;
    }

    switch (mamaMsgStatus_statusForMsg (msg))
    {
    case MAMA_MSG_STATUS_BAD_SYMBOL:
    case MAMA_MSG_STATUS_EXPIRED:
    case MAMA_MSG_STATUS_TIMEOUT:
        mamaSubscription_destroy (subscription);
        mamaSubscription_deallocate (subscription);
        if (cache->pub)
            mamaDQPublisher_send(cache->pub, msg);
        cache->sub = NULL;
        return;
    default:
        break;
    }

    mamaMsg_applyMsg(cache->cachedMsg, msg);

    if (cache->pub)
    {
        mamaDQPublisher_setStatus(cache->pub, mamaMsgStatus_statusForMsg (msg));
        mamaDQPublisher_send(cache->pub, msg);
    }

    fflush(stdout);
}
示例#2
0
void mamaDQPublisherManager_destroy (mamaDQPublisherManager manager)
{
    /* Get the impl. */
    mamaDQPublisherManagerImpl* impl  = (mamaDQPublisherManagerImpl*) manager;
    if(NULL != impl)
    {
        /* Destroy the publisher. */
        if(NULL != impl->mPublisher)
        {
            mamaPublisher_destroy(impl->mPublisher);
        }

        /* Destroy the subscription. */
        if(NULL != impl->mSubscription)
        {
            mamaSubscription_destroy(impl->mSubscription);
            mamaSubscription_deallocate(impl->mSubscription);
        }

        /* Destroy the inbox. */
        if(NULL != impl->mInbox)
        {
            mamaInbox_destroy(impl->mInbox);
        }

        /* Destroy the re-usable messages. */
        if(NULL != impl->mRefreshResponseMsg)
        {
            mamaMsg_destroy(impl->mRefreshResponseMsg);
        }
        if(NULL != impl->mNoSubscribersMsg)
        {
            mamaMsg_destroy(impl->mNoSubscribersMsg);
        }
        if(NULL != impl->mSyncRequestMsg)
        {
            mamaMsg_destroy(impl->mSyncRequestMsg);
        }

        /* Free the namespace. */
        if(NULL != impl->mNameSpace)
        {
            free(impl->mNameSpace);
        }

        /* Destroy the publisher table. */
        if(NULL != impl->mPublisherMap)
        {
            wtable_destroy ( impl->mPublisherMap );
        }

        /* Free the impl itself. */
        free(impl);
    }
}
/*
 * Stop subscription, transport and MAMA
 */
void stopAll()
{
    // order is important
    if (global.subscription)
    {
        mamaSubscription_destroy(global.subscription);
        global.subscription = NULL;
    }
    mama_stop(global.bridge);
    if (global.transport)
    {
        mamaTransport_destroy(global.transport);
        global.transport = NULL;
    }
}
示例#4
0
mama_status
avisBridgeMamaInbox_destroy (inboxBridge inbox)
{
    mamaSubscription sub = NULL;

    CHECK_INBOX(inbox);

    /* Store subscription before callign destroy as the inbox might be
     * freed before we get a chance to deallocate it. */
    sub = avisInbox(inbox)->mSubscription;

    mamaSubscription_destroy(sub);
    mamaSubscription_deallocate(sub);

    return MAMA_STATUS_OK;
}
示例#5
0
static void 
processMsg( mamaDictionary dictionary, const mamaMsg msg )
{
    mamaMsgStatus     msgStatus = -1;
    mamaMsgType       msgType = -1;

    msgStatus = mamaMsgStatus_statusForMsg( msg ); 
    msgType   = mamaMsgType_typeForMsg( msg );

    if( msgStatus == MAMA_MSG_STATUS_TIMEOUT )
    {
        self->mCallbackSet.onTimeout( dictionary, self->mClosure );
        return;
    }

    if( msgStatus != MAMA_MSG_STATUS_OK && 
        msgType   != MAMA_MSG_TYPE_DDICT_SNAPSHOT &&
        msgType   != MAMA_MSG_TYPE_UPDATE ) 
    {
        char errBuf[1024];

        snprintf( errBuf, 1023, "Error: mamaDictionary: unexpected "
                                    "MsgType/MsgStatus: %s/%s\n",
               mamaMsgType_stringForType(msgType),
               mamaMsgStatus_stringForStatus(msgStatus));

        self->mCallbackSet.onError( dictionary, errBuf, self->mClosure );
        return;
    }

    mamaDictionary_buildDictionaryFromMessage( dictionary, msg );

    mamaSubscription_destroy (self->mSubscription);
    mamaSubscription_deallocate (self->mSubscription);
    self->mSubscription = NULL;

    /* do this last in case the dictionary transport is destroyed
       in the callback */
    self->mCallbackSet.onComplete( dictionary, self->mClosure );
}
示例#6
0
mama_status
mamaDictionary_destroy (mamaDictionary dictionary)
{
    uint32_t i = 0; 

    if (dictionary == NULL) return MAMA_STATUS_OK;

    if (self->mDict)
    {
        for (i = 0; i <= self->mMaxFid; ++i)
        {
            if (self->mDict[i] )
	        {   
                mamaFieldDescriptor_destroy (self->mDict[i]);
	        }
        }
    }

    if (self->mSubscription)
    {
        mamaSubscription_destroy (self->mSubscription);
        mamaSubscription_deallocate (self->mSubscription);
    }

    if (self->mDict)
    {
        free(self->mDict);
    }
    
    checkFree(&self->mFeedName);
    checkFree(&self->mFeedHost);

    memset (self, 0, sizeof( mamaDictionaryImpl));
    free (self);

    return MAMA_STATUS_OK;
}
示例#7
0
mama_status
mamaCaptureList_deallocate (mamaCaptureList captureList)
{
    mamaCaptureSourceList* sourceList =
        (mamaCaptureSourceList*)captureList;
    int i;
    for (i = 0; i < gCounter; i++)
    {
        free ((char*)sourceList[i].mySymbolNamespace);
        free ((char*)sourceList[i].myTransportName);
        free ((char*)sourceList[i].mySymbol);
        mamaSubscription_destroy (sourceList[i].mySubscription);
        mamaSubscription_deallocate (sourceList[i].mySubscription);
        mamaSource_destroy (sourceList[i].mySource);
        if (sourceList[i].myTransport != NULL)
        {
            mamaTransport_destroy (sourceList[i].myTransport);
            sourceList[i].myTransport = NULL;
        }
    }
    free (sourceList);

    return MAMA_STATUS_OK;
}