void
d_statusListenerInit(
    d_statusListener listener,
    d_subscriber subscriber)
{
    d_admin admin;
    d_durability durability;
    d_configuration config;

    admin = d_subscriberGetAdmin(subscriber);
    durability = d_adminGetDurability(admin);
    config = d_durabilityGetConfiguration(durability);

    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);
    assert(d_objectIsValid(d_object(admin), D_ADMIN) == TRUE);
    assert(d_objectIsValid(d_object(durability), D_DURABILITY) == TRUE);
    assert(d_objectIsValid(d_object(config), D_CONFIGURATION) == TRUE);

    d_readerListenerInit(   d_readerListener(listener),
                            d_statusListenerAction, subscriber,
                            D_STATUS_TOPIC_NAME, D_STATUS_TOP_NAME,
                            V_RELIABILITY_RELIABLE,
                            V_HISTORY_KEEPLAST,
                            1, config->heartbeatScheduling,
                            d_statusListenerDeinit);
    listener->cleanupAction = NULL;
}
Exemple #2
0
c_bool
d_readerRequestRemoveChain(
    d_readerRequest request,
    d_chain chain)
{
    d_chain found;
    c_bool result;

    assert(d_objectIsValid(d_object(request), D_READER_REQUEST) == TRUE);
    assert(d_objectIsValid(d_object(chain), D_CHAIN) == TRUE);

    if(request && chain){
        d_lockLock(d_lock(request));
        found = d_tableRemove(request->requests, chain);
        d_lockUnlock(d_lock(request));

        if(found){
            result = TRUE;
            d_chainFree(found);
        } else {
            result = FALSE;
        }
    } else {
        result = FALSE;
    }
    return result;
}
Exemple #3
0
void
d_lockInit(
    d_lock lock,
    d_kind kind,
    d_objectDeinitFunc deinit)
{
    os_mutexAttr attr;
    os_result osr;
    
    d_objectInit(d_object(lock), kind, d_lockDeinit);
    
    if(lock){
        lock->deinit = deinit;
        osr = os_mutexAttrInit(&attr);
        
        if(osr == os_resultSuccess){
            attr.scopeAttr = OS_SCOPE_PRIVATE;
            osr = os_mutexInit(&lock->lock, &attr);
            
            if(osr != os_resultSuccess){
                d_objectFree(d_object(lock), kind);
            }
        } else {
            d_objectFree(d_object(lock), kind);
        }
    }
}
Exemple #4
0
c_bool
d_readerRequestAddGroup(
    d_readerRequest request,
    d_group group)
{
    c_bool result;
    d_group found;

    assert(d_objectIsValid(d_object(request), D_READER_REQUEST) == TRUE);

    if(request){
        d_lockLock(d_lock(request));
        found = d_tableInsert(request->groups, group);
        d_lockUnlock(d_lock(request));

        if(!found){
            d_objectKeep(d_object(group));
            result = TRUE;
        } else {
            result = FALSE;
        }
    } else {
        result = FALSE;
    }
    return result;
}
Exemple #5
0
void
d_subscriberFree(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);

    if(subscriber){
        d_objectFree(d_object(subscriber), D_SUBSCRIBER);
    }
}
Exemple #6
0
void
d_waitsetEntityFree(
    d_waitsetEntity we)
{
    assert(d_objectIsValid(d_object(we), D_WAITSET_ENTITY) == TRUE);

    if(we) {
        d_objectFree(d_object(we), D_WAITSET_ENTITY);
    }
}
Exemple #7
0
void
d_eventListenerFree(
    d_eventListener listener)
{
    assert(d_objectIsValid(d_object(listener), D_EVENT_LISTENER) == TRUE);

    if(listener) {
        d_objectFree(d_object(listener), D_EVENT_LISTENER);
    }
}
Exemple #8
0
void
d_publisherFree(
    d_publisher publisher)
{
    assert(d_objectIsValid(d_object(publisher), D_PUBLISHER) == TRUE);

    if(publisher){
        d_objectFree(d_object(publisher), D_PUBLISHER);
    }
}
Exemple #9
0
void
d_lockFree(
    d_lock lock,
    d_kind kind)
{
    assert(d_objectIsValid(d_object(lock), kind) == TRUE);
    
    if(lock){
        d_objectFree(d_object(lock), kind);
    }
}
Exemple #10
0
c_bool
d_waitsetDetach(
    d_waitset waitset,
    d_waitsetEntity we)
{
    u_result ur;
    c_bool result = FALSE;
    int i;
    d_waitsetHelper helper;

    helper = NULL;

    assert(d_objectIsValid(d_object(waitset), D_WAITSET) == TRUE);
    assert(d_objectIsValid(d_object(we), D_WAITSET_ENTITY) == TRUE);

    if(waitset && we){
        d_lockLock(d_lock(waitset));

        if(c_iterContains(waitset->entities, we) == TRUE) {
            if(waitset->runToCompletion == TRUE){
                ur = u_waitsetDetach(waitset->uwaitset, u_entity(we->dispatcher));
            } else {
                for(i=0; i<c_iterLength(waitset->threads) && !helper; i++){
                    helper = d_waitsetHelper(c_iterObject(waitset->threads, i));

                    if(helper->entity != we){
                        helper = NULL;
                    }
                }
                assert(helper);
                c_iterTake(waitset->threads, helper);
                helper->terminate = TRUE;
                u_waitsetNotify(helper->userWaitset, NULL);
                os_threadWaitExit(helper->tid, NULL);
                ur = u_waitsetDetach(helper->userWaitset, u_entity(we->dispatcher));
                u_waitsetFree(helper->userWaitset);
                os_free(helper);
            }
            if(ur == U_RESULT_OK) {
                c_iterTake(waitset->entities, we);
                we->waitset = NULL;
                result = TRUE;
            }
        }
        d_lockUnlock(d_lock(waitset));
    }
    return result;
}
Exemple #11
0
u_subscriber
d_subscriberGetPersistentSubscriber(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);
    return subscriber->persistentSubscriber;
}
Exemple #12
0
d_table
d_tableNew(
    int ( *  compare )(),
    void ( * cleanAction )() )
{
    d_table table;

    assert(compare != 0);
    /* Allocate table object */
    table = (d_table)d_malloc(C_SIZEOF(d_table), "Table");
    if (table) {
        /* QAC EXPECT 3892; */
        /* Call super-init */
        d_objectInit(d_object(table), D_TABLE,
                     (d_objectDeinitFunc)d_tableDeinit);
        /* Initialize table object */
        ut_avlCTreedefInit (&table->td,
                            offsetof (C_STRUCT(d_tableNode), avlnode), offsetof (C_STRUCT(d_tableNode), object),
                            (int (*) (const void *, const void *)) compare, 0,
                            UT_AVL_TREEDEF_FLAG_INDKEY);
        ut_avlCInit (&table->td, &table->tree);
        table->cleanAction = cleanAction;
    }
    return table;
}
Exemple #13
0
d_waitsetEntity
d_waitsetEntityNew(
    const c_char* name,
    u_dispatcher dispatcher,
    d_waitsetAction action,
    c_ulong mask,
    os_threadAttr attr,
    c_voidp usrData)
{
    d_waitsetEntity we = NULL;

    assert(dispatcher);
    assert(action);

    if(dispatcher && action) {
        we = d_waitsetEntity(os_malloc(C_SIZEOF(d_waitsetEntity)));

        if(name){
            we->name   = os_strdup(name);
        } else {
            we->name   = os_strdup("waitsetEntity");
        }
        we->action     = action;
        we->dispatcher = dispatcher;
        we->mask       = mask;
        we->usrData    = usrData;
        we->attr       = attr;
        we->waitset    = NULL;

        d_objectInit(d_object(we), D_WAITSET_ENTITY, d_waitsetEntityDeinit);
    }
    return we;
}
Exemple #14
0
void
d_readerListenerInitDataReader(
    d_readerListener listener,
    d_subscriber subscriber,
    const c_char* name,
    v_reliabilityKind reliability,
    v_historyQosKind historyKind,
    c_long historyDepth)
{
    v_readerQos readerQos;
    u_subscriber s;
    d_networkAddress unaddressed, myAddr;
    d_admin admin;
    c_char *query;
    q_expr expr;

    assert(d_objectIsValid(d_object(listener), D_LISTENER));

    if(listener && subscriber){
        readerQos = d_readerQosNew(V_DURABILITY_VOLATILE, reliability);
        readerQos->history.kind = historyKind;
        readerQos->history.depth = historyDepth;
        readerQos->lifecycle.autopurge_nowriter_samples_delay.seconds = 60;
        readerQos->lifecycle.autopurge_nowriter_samples_delay.nanoseconds = 0;
        readerQos->lifecycle.autopurge_disposed_samples_delay.seconds = 10;
        readerQos->lifecycle.autopurge_disposed_samples_delay.nanoseconds = 0;
        s = d_subscriberGetSubscriber(subscriber);
        admin       = d_subscriberGetAdmin(subscriber);
        myAddr      = d_adminGetMyAddress(admin);
        unaddressed = d_networkAddressUnaddressed();

        /*
         * Message is:
         * - meant for me or
         * - meant for all and not sent by me
         */
#define FILTER_EXPRESSION "select * from %s where " \
                          "parentMsg.addressee.systemId=%u OR " \
                          "parentMsg.addressee.systemId=%u AND " \
                          "parentMsg.senderAddress.systemId!=%u"

        query = (c_char*)(os_malloc(strlen(listener->name) +
                                    strlen(FILTER_EXPRESSION) + 32));
        os_sprintf(query, FILTER_EXPRESSION, listener->name,
                myAddr->systemId, unaddressed->systemId, myAddr->systemId);

        expr = q_parse(query);

        listener->dataReader =
                u_dataReaderNew (s, name, expr, NULL, readerQos, TRUE);

        q_dispose(expr);
        os_free(query);

#undef FILTER_EXPRESSION
        d_networkAddressFree(myAddr);
        d_networkAddressFree(unaddressed);
        d_readerQosFree(readerQos);
    }
}
Exemple #15
0
d_waitset
d_subscriberGetWaitset(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);
    return subscriber->waitset;
}
Exemple #16
0
d_admin
d_subscriberGetAdmin(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);
    return subscriber->admin;
}
Exemple #17
0
void
d_readerListenerFree(
    d_readerListener listener)
{
    assert(d_objectIsValid(d_object(listener), D_LISTENER));

    if(listener){
        d_listenerFree(d_listener(listener));
    }
}
Exemple #18
0
void
d_tableFree(
    d_table table )
{
    assert(d_tableIsValid(table));

    if (table) {
        d_objectFree(d_object(table));
    }
}
Exemple #19
0
void
d_waitsetFree(
    d_waitset waitset)
{
    assert(d_objectIsValid(d_object(waitset), D_WAITSET) == TRUE);

    if(waitset){
        d_lockFree(d_lock(waitset), D_WAITSET);
    }
}
Exemple #20
0
static c_bool
addGroup(
    d_group group,
    c_voidp args)
{
    d_table table;

    table = d_table(args);
    d_tableInsert(table, d_objectKeep(d_object(group)));
    return TRUE;
}
Exemple #21
0
void
d_subscriberInitGroupsRequestListener(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);

    if(!subscriber->groupsRequestListener){
        subscriber->groupsRequestListener = d_groupsRequestListenerNew(subscriber);
        assert(subscriber->groupsRequestListener);
    }
}
Exemple #22
0
void
d_subscriberInitSampleChainListener(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);

    if(!subscriber->sampleChainListener){
        subscriber->sampleChainListener = d_sampleChainListenerNew(subscriber);
        assert(subscriber->sampleChainListener);
    }
}
Exemple #23
0
void
d_subscriberInitDeleteDataListener(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);

    if(!subscriber->deleteDataListener){
        subscriber->deleteDataListener = d_deleteDataListenerNew(subscriber);
        assert(subscriber->deleteDataListener);
    }
}
Exemple #24
0
void
d_subscriberInitNameSpacesListener(
    d_subscriber subscriber)
{
    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);

    if(!subscriber->nameSpacesListener){
        subscriber->nameSpacesListener = d_nameSpacesListenerNew(subscriber);
        assert(subscriber->nameSpacesListener);
    }
}
void
d_groupCreationQueueFree(
    d_groupCreationQueue queue)
{
    assert(d_objectIsValid(d_object(queue), D_GROUP_CREATION_QUEUE) == TRUE);

    if(queue) {
        d_lockFree(d_lock(queue), D_GROUP_CREATION_QUEUE);
    }
    return;
}
static void
collectNsWalk(
    d_nameSpace ns, void* userData)
{
    c_iter nameSpaces = (c_iter)userData;
    if (ns)
    {
        d_objectKeep(d_object(ns));
        c_iterInsert (nameSpaces, ns);
    }
}
Exemple #27
0
void
d_readerRequestFree(
    d_readerRequest request)
{
    assert(d_objectIsValid(d_object(request), D_READER_REQUEST) == TRUE);

    if(request){
        d_lockFree(d_lock(request), D_READER_REQUEST);
    }
    return;
}
Exemple #28
0
d_subscriber
d_waitsetGetSubscriber(
    d_waitset waitset)
{
    d_subscriber subscriber = NULL;

    assert(d_objectIsValid(d_object(waitset), D_WAITSET) == TRUE);

    if(waitset) {
        subscriber = waitset->subscriber;
    }
    return subscriber;
}
Exemple #29
0
c_voidp
d_eventListenerGetUserData(
    d_eventListener listener)
{
    c_voidp userData = NULL;

    assert(d_objectIsValid(d_object(listener), D_EVENT_LISTENER) == TRUE);

    if(listener) {
        userData = listener->args;
    }
    return userData;
}
Exemple #30
0
d_nameSpacesRequestListener
d_subscriberGetNameSpacesRequestListener(
    d_subscriber subscriber)
{
    d_nameSpacesRequestListener listener = NULL;

    assert(d_objectIsValid(d_object(subscriber), D_SUBSCRIBER) == TRUE);

    if(subscriber){
        listener = subscriber->nameSpacesRequestListener;
    }
    return listener;
}