コード例 #1
0
static c_bool
idl_isCatsDefFor(
    c_metaObject scope,
    c_char *typeName,
    c_char *key)
{
    idl_catsDef catsDef = idl_catsDefDefGet();
    idl_catsMap catsMap;
    c_long catsMapIdx;
    c_iter catsList;
    os_uint32 catsListSize;
    os_uint32 catsIdx;

    if (catsDef != NULL) {
        /* check all cats definition list elements */
        for (catsMapIdx = 0; catsMapIdx < c_iterLength(catsDef->catsList); catsMapIdx++) {
            catsMap = c_iterObject(catsDef->catsList, catsMapIdx);
            if (c_metaCompare(scope, catsMap->scope) == E_EQUAL &&
                strcmp(typeName, catsMap->typeName) == 0)
            {
                /* for each cats in catsList, check if it's equal to key */
                catsList = c_splitString(catsMap->catsList, ",");
                catsListSize = c_iterLength(catsList);
                for(catsIdx = 0; catsIdx < catsListSize; catsIdx++)
                {
                    if (strcmp(c_iterTakeFirst(catsList), key) == 0) {
                        return OS_TRUE;
                    }
                }
            }
        }
    }

    return OS_FALSE;
}
コード例 #2
0
jni_result
jni_participantFree(
    jni_participant p)
{
    jni_result r;
    jni_partition partition;
    
    r = JNI_RESULT_OK;
    
    if(p != NULL){
        if((p->publishers != NULL) && (c_iterLength(p->publishers) != 0)){
            r = JNI_RESULT_PRECONDITION_NOT_MET;
        }
        else if((p->subscribers != NULL) && (c_iterLength(p->subscribers) != 0)){
            r = JNI_RESULT_PRECONDITION_NOT_MET;
        }
        else if((p->topics != NULL) && (c_iterLength(p->topics) != 0)){
            r = JNI_RESULT_PRECONDITION_NOT_MET;
        }
        else if((p->partitions != NULL) && (c_iterLength(p->partitions) != 0)){
            partition = jni_partition(c_iterTakeFirst(p->partitions));
            
            while((partition != NULL) && (r == JNI_RESULT_OK)){
                r = jni_partitionFree(partition);
                partition = jni_partition(c_iterTakeFirst(p->partitions));
            }
        }
        else{
          /*DO NOTHING.*/
        }
        
        if(r == JNI_RESULT_OK){
            if(p->publishers != NULL){
                c_iterFree(p->publishers);
            }
            if(p->subscribers != NULL){
                c_iterFree(p->subscribers);
            }
            if(p->topics != NULL){
                c_iterFree(p->topics);
            }
            if(p->partitions != NULL){
                c_iterFree(p->partitions);
            }
            if(p->uparticipant != NULL){
                r = jni_convertResult(u_participantFree(p->uparticipant));
            }
            else{
                r = JNI_RESULT_OK;
            }
            os_free(p);
        }        
    }
    else{
        r = JNI_RESULT_BAD_PARAMETER;
    }
    return r;
}
コード例 #3
0
ファイル: cms_service.c プロジェクト: shizhexu/opensplice
static void*
cms_serviceCollectGarbage(
    void* arg)
{
    cms_service cms;
    os_time update;
    cms_thread client;
    c_bool garbagePresent;

    cms = cms_service(arg);
    update.tv_sec = 2;
    update.tv_nsec = 0;

    garbagePresent = FALSE;

    /*
     * Keep going until service terminates AND all garbage has been collected.
     */
    while((cms->terminate == FALSE) || (c_iterLength(cms->clientGarbage) != 0)) {
        os_mutexLock(&cms->clientMutex);
        client = cms_thread(c_iterTakeFirst(cms->clientGarbage));
        os_mutexUnlock(&cms->clientMutex);

        while(client != NULL) {
            /*
             * Call threadFree and NOT clientFree on purpose.
             */
            cms_threadFree(client);
            os_mutexLock(&cms->clientMutex);
            client = cms_thread(c_iterTakeFirst(cms->clientGarbage));
            os_mutexUnlock(&cms->clientMutex);
            garbagePresent = TRUE;
        }

        if((c_iterLength(cms->clients) == 0) && (garbagePresent == TRUE)) {
            if(cms->configuration->verbosity >= 3) {
                OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                          "No clients connected. Performing some garbage collecting...");
            }
            cmx_deregisterAllEntities();
            garbagePresent = FALSE;
        }


        if(cms->terminate == FALSE) {
            os_nanoSleep(update);
        }
    }
    c_iterFree(cms->clientGarbage);

    return NULL;
}
コード例 #4
0
ファイル: u_dispatcher.c プロジェクト: S73417H/opensplice
u_result
u_dispatcherRemoveListener(
    u_dispatcher _this,
    u_dispatcherListener listener)
{
    u_listener ul;
    v_observer ko;
    os_threadId tid;
    u_result result = U_RESULT_OK;
    struct compareArg arg;

    if ((_this != NULL) && (listener != NULL)) {
        os_mutexLock(&_this->mutex);
        arg.listener = listener;
        ul = (u_listener) c_iterResolve(_this->listeners, compare, &arg);
        tid = _this->threadId;
        if (ul != NULL) {
            c_iterTake(_this->listeners, ul);
            if (c_iterLength(_this->listeners) == 0) {
                result = u_entityReadClaim(u_entity(_this), (v_entity*)(&ko));
                if(result == U_RESULT_OK) {
                    assert(ko);
                    /* Wakeup the dispatch thread */
                    v_observerLock(ko);
                    v_observerNotify(ko, NULL, NULL);
                    v_observerUnlock(ko);
                    result = u_entityRelease(u_entity(_this));
                    if (result != U_RESULT_OK) {
                        OS_REPORT(OS_ERROR, "u_dispatcherRemoveListener", 0,
                                  "Release observer failed.");
                    }
                } else {
                    OS_REPORT(OS_WARNING, "u_dispatcherRemoveListener", 0,
                              "Failed to claim Dispatcher.");
                }
            }
            u_listenerFree(ul);
        }
        os_mutexUnlock(&_this->mutex);
        if ((c_iterLength(_this->listeners) == 0)
            && (os_threadIdToInteger(tid) != 0U)) {
            os_threadWaitExit(tid, NULL);
        }
    } else {
        OS_REPORT(OS_ERROR,"u_dispatcherInsertListener",0,
                  "Illegal parameter.");
        result = U_RESULT_ILL_PARAM;
    }
    return result;
}
コード例 #5
0
ファイル: idl_keyDef.c プロジェクト: S73417H/opensplice
c_char *
idl_keyResolve2 (
    idl_keyDef keyDef,
    c_metaObject scope,
    const char *typeName)
{
    c_long li;
    idl_keyMap keyMap;

    li = 0;
    /* check all key definition list elements */
    while (li < c_iterLength (keyDef->keyList))
    {
        keyMap = c_iterObject (keyDef->keyList, li);
        if (strcmp(typeName, keyMap->typeName) == 0)
        {
            /* if the typename equals, check if the scope compares */
            if(scope == keyMap->scope)
            {
                return keyMap->keyList;
            }
	    }
	    li++;
    }
    return NULL;
}
コード例 #6
0
std::vector<org::opensplice::sub::AnyDataReaderDelegate::ref_type>
SubscriberDelegate::get_datareaders(
    const dds::sub::status::DataState& mask)
{
    org::opensplice::core::ScopedObjectLock scopedLock(*this);

    std::vector<org::opensplice::sub::AnyDataReaderDelegate::ref_type> readers;
    u_dataReader uReader;
    u_sampleMask uMask;
    u_result uResult;
    c_iter uList;

    /* Get list from user layer. */
    uMask = org::opensplice::sub::AnyDataReaderDelegate::getUserMask(mask);
    uResult = u_subscriberGetDataReaders(u_subscriber(this->userHandle), uMask, &uList);
    ISOCPP_U_RESULT_CHECK_AND_THROW(uResult, "Could not get datareaders.");

    /* Translate user layer list. */
    readers.reserve(c_iterLength(uList));
    while ((uReader = u_dataReader(c_iterTakeFirst(uList))) != NULL) {
        org::opensplice::core::ObjectDelegate::ref_type reader =
                org::opensplice::core::EntityDelegate::extract_strong_ref(u_entity(uReader));
        if (reader) {
            readers.push_back(OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<AnyDataReaderDelegate>(reader));
        }
    }
    c_iterFree(uList);

    return readers;
}
コード例 #7
0
ファイル: sr_serviceInfo.c プロジェクト: diorahman/opensplice
/**************************************************************
 * Private functions
 **************************************************************/
static c_bool
cfgGetCommand(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int      iterLength;
    c_bool r;
    u_cfData d;

    r = TRUE;

    iter = u_cfElementXPath(info, "Command/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &si->command);
        u_cfDataFree(d);
    } else {
        OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
            0, "One <Command> parameter expected for service %s", si->name);
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
        r = FALSE;
    }
    c_iterFree(iter);

    return r;
}
コード例 #8
0
ファイル: c_metafactory.c プロジェクト: xrl/opensplice_dds
c_array
c_metaArray(
    c_metaObject scope,
    c_iter iter,
    c_metaKind kind)
{
    c_long i;
    struct copyToArrayArg arg;
    c_type type;

    if (kind) {
        /* suppress warnings */
    }
    i = c_iterLength(iter);
    if (i == 0) {
        arg.a = NULL;
    } else {
        type = c_object_t(c__getBase(scope));
        arg.a = c_arrayNew(type,i);
        arg.index = 0;
        c_iterWalk(iter,copyToArray,&arg);
        c_iterFree(iter);
        c_free(type);
    }
    return arg.a;
}
コード例 #9
0
ファイル: v_entry.c プロジェクト: xrl/opensplice
void
v_entryRemoveGroup(
    v_entry entry,
    v_group group)
{
    c_query query;
    q_expr qExpr;
    c_value params[2];
    c_iter groups;
    v_proxy proxy, proxy2;
    v_handle handle;

    assert(entry != NULL);
    assert(C_TYPECHECK(entry,v_entry));
    assert(group != NULL);
    assert(C_TYPECHECK(group,v_group));

    handle = v_publicHandle(v_public(group));
    qExpr = (q_expr)q_parse("source.index = %0 and source.server = %1");
    params[0] = c_longValue(handle.index);
    params[1] = c_addressValue(handle.server);

    query = c_queryNew(entry->groups, qExpr, params);
    q_dispose(qExpr);
    groups = c_select(query, 0);
    c_free(query);
    assert(c_iterLength(groups) <= 1);
    proxy = v_proxy(c_iterTakeFirst(groups));
    proxy2 = c_remove(entry->groups, proxy, NULL, NULL);
    c_iterFree(groups);
    c_free(proxy);
    c_free(proxy2);
}
コード例 #10
0
ファイル: sr_serviceInfo.c プロジェクト: diorahman/opensplice
static c_bool
cfgGetArguments(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int    iterLength;
    c_bool r;
    u_cfData d;

    r = TRUE;
    iter = u_cfElementXPath(info, "Arguments/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &si->args);
        u_cfDataFree(d);
    } else if (iterLength == 0) {
        OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
            0, "Taking default for <Arguments> parameter service %s", si->name);
        si->args = os_strdup("");
    } else {
        OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
            0, "One <Arguments> parameter expected for service %s", si->name);
        si->args = os_strdup("");
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
        r = FALSE;
    }
    c_iterFree(iter);

    return r;
}
コード例 #11
0
ファイル: u_usrClock.c プロジェクト: osrf/opensplice
static const char *
u_usrClockConfigElementDataString (
    const cf_element element,
    const char *defaultValue)
{
    c_iter children;
    const char *data = defaultValue;
    c_value dataValue;
    c_ulong i;
    cf_node node;

    assert(element != NULL);

    children = cf_elementGetChilds (element);

    if (children) {
        for (i = 0; i < c_iterLength (children); i++) {
            node = c_iterObject (children, i);

            if (cf_nodeKind (node) == CF_DATA) {
                dataValue = cf_dataValue (cf_data(node));

                if (dataValue.kind == V_STRING) {
                    data = dataValue.is.String;
                }
            }
        }
        c_iterFree(children);
    }
    return data;
}
コード例 #12
0
ファイル: u_reader.c プロジェクト: S73417H/opensplice
c_long
u_readerQueryCount(
    u_reader _this)
{
    c_long length = -1;
    os_result r;

    if (_this) {
        if(u_entityOwner(u_entity(_this))) {
            r = os_mutexLock(&_this->mutex);
            if (r == os_resultSuccess) {
                length = c_iterLength(_this->queries);
                os_mutexUnlock(&_this->mutex);
            } else {
                OS_REPORT(OS_WARNING,
                          "u_readerRemoveQuerie",0,
                          "Failed to lock Reader.");
            }
        }
    } else {
        OS_REPORT(OS_WARNING,
                  "u_readerQueryCount",0,
                  "No Reader specified.");
    }
    return length;
}
コード例 #13
0
ファイル: u_reader.c プロジェクト: S73417H/opensplice
u_result
u_readerGetMatchedPublications (
    u_reader _this,
    v_statusAction action,
    c_voidp arg)
{
    v_dataReader reader;
    v_spliced spliced;
    v_kernel kernel;
    u_result result;
    c_iter participants;
    v_participant participant;

    result = U_RESULT_PRECONDITION_NOT_MET;
    if (_this != NULL) {
        result = u_entityReadClaim(u_entity(_this), (v_entity*)(&reader));

        if ((result == U_RESULT_OK) && (reader != NULL)) {
            kernel = v_objectKernel(reader);

            participants = v_resolveParticipants(kernel, V_SPLICED_NAME);
            assert(c_iterLength(participants) == 1);
            participant = v_participant(c_iterTakeFirst(participants));
            spliced = v_spliced(participant);
            c_free(participant);
            c_iterFree(participants);

            result = u_resultFromKernel(
                         v_splicedGetMatchedPublications(spliced, v_dataReader(reader), action, arg));
            u_entityRelease(u_entity(_this));
        }
    }
    return result;
}
コード例 #14
0
ファイル: idl_stacDef.c プロジェクト: osrf/opensplice
os_boolean
idl_stacListItemIsMemberLocated(
    const c_char* list,
    const char* itemName)
{
    os_boolean isDefined = OS_FALSE;

    if(list)
    {
        c_iter items;
        c_char* item;

        items = c_splitString(list, ",");
        while(c_iterLength(items) > 0 && !isDefined)
        {
            item = c_iterTakeFirst(items);
            if(item && 0 == strcmp(item, itemName))
            {
                isDefined = OS_TRUE;
            }
        }
    }

    return isDefined;
}
コード例 #15
0
static c_bool
v_partitionAdminRemoveExpression(
    v_partitionAdmin da,
    const char *partitionExpr)
{
    c_bool result = FALSE;
    v_partitionInterest partitionInterest, found;
    q_expr expr;
    c_collection q;
    c_iter list;
    c_value params[1];

    assert(!v_partitionExpressionIsAbsolute(partitionExpr));

    expr = (q_expr)q_parse("expression like %0");
    params[0] = c_stringValue((char *)partitionExpr);
    q = c_queryNew(da->partitionInterests, expr, params);
    q_dispose(expr);
    list = ospl_c_select(q,0);
    assert(c_iterLength(list) <= 1);
    partitionInterest = v_partitionInterest(c_iterTakeFirst(list));
    while (partitionInterest) {
        result = TRUE;
        found = c_tableRemove(da->partitionInterests, partitionInterest, NULL, NULL);
        c_free(partitionInterest);
        c_free(found);
        partitionInterest = v_partitionInterest(c_iterTakeFirst(list));
    }
    c_free(q);
    c_iterFree(list);

    return result;
}
コード例 #16
0
ファイル: dbg_common.c プロジェクト: S73417H/opensplice
static void
printStructure(
    c_structure _this,
    toolActionData actionData)
{
    c_object o;
    c_object object;
    c_long i, size;
    c_member member;

    o = c_iterObject(actionData->stack, 0);

    if (o) {
        if (c_iterLength(actionData->stack) == 1) {
            printf("%s ", _METANAME(_this));
        } else {
        }
        printf("{\n");
        size = c_structureMemberCount(_this);
        for (i=0; i<size; i++) {
            member = c_structureMember(_this, i);
            object = C_DISPLACE(o, (c_address)member->offset);
            if (c_typeIsRef(c_memberType(member))) {
                iprintf("    %s <0x"PA_ADDRFMT">\n",
                       c_specifierName(member),
                       *(os_address *)object);
            } else {
                OBJECT_PUSH(actionData, object);
                iprintf("%s ",c_specifierName(member));
                printType(c_memberType(member), actionData);
                printf("\n");
                OBJECT_POP(actionData);
            }
        }
        if (c_iterLength(actionData->stack) == 1) {
            iprintf("};");
        } else {
            iprintf("} %s;", _METANAME(_this));
        }
        if (c_type(_this) == v_handle_t) {
            v_object vo;
            v_handleClaim(*(v_handle *)o,&vo);
            v_handleRelease(*(v_handle *)o);
            printf(" /* Handle's object: <0x"PA_ADDRFMT"> */", (os_address)vo);
        }
    }
}
コード例 #17
0
ファイル: idl_stacDef.c プロジェクト: osrf/opensplice
/* Check if there is a stac applied to the given key. */
c_bool
idl_isStacDefFor(
    c_metaObject scope,
    c_char *typeName,
    c_char *key)
{
    idl_stacDef stacDef = idl_stacDefDefGet();
    idl_stacMap stacMap;
    c_ulong stacMapIdx;
    c_iter stacList;
    os_uint32 stacListSize;
    os_uint32 stacIdx;
    os_boolean stacDefFor = OS_FALSE;

    if (stacDef != NULL) {
        /* check all stac definition list elements */
        for (stacMapIdx = 0; stacMapIdx < c_iterLength(stacDef->stacList) && !stacDefFor; stacMapIdx++) {
            stacMap = c_iterObject(stacDef->stacList, stacMapIdx);
            if (c_metaCompare(scope, stacMap->scope) == E_EQUAL &&
                strcmp(typeName, stacMap->typeName) == 0)
            {
                /* for each stac in stacList, check if it's equal to key */
                stacList = c_splitString(stacMap->stacList, ",");
                stacListSize = c_iterLength(stacList);
                if (stacListSize == 0) {
                    stacDefFor = OS_TRUE;
                }
                else if(idl_stacDefOnlyExclusionsDefined(stacMap->stacList))
                {
                    if(!idl_stacDefIsFieldExcluded(stacMap->stacList, key))
                    {
                        stacDefFor = OS_TRUE;
                    }
                } else
                {
                    for(stacIdx = 0; stacIdx < stacListSize; stacIdx++)
                    {
                        if (strcmp(c_iterTakeFirst(stacList), key) == 0) {
                            stacDefFor = OS_TRUE;
                        }
                    }
                }
            }
        }
    }
    return stacDefFor;
}
コード例 #18
0
ファイル: sr_serviceInfo.c プロジェクト: diorahman/opensplice
static c_bool
cfgGetSchedule(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int      iterLength;
    c_bool r;
    u_cfData d;
    c_char *str;

    r = TRUE;
    iter = u_cfElementXPath(info, "Scheduling/Class/#text");
    iterLength = c_iterLength(iter);
    d = u_cfData(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfDataStringValue(d, &str);

        if (r == TRUE) {
            if (strncmp(str, SCHED_RT, strlen(SCHED_RT)) == 0) {
                si->procAttr.schedClass = OS_SCHED_REALTIME;
            } else {
                if (strncmp(str, SCHED_TS, strlen(SCHED_TS)) == 0) {
                    si->procAttr.schedClass = OS_SCHED_TIMESHARE;
                } else {
                    if (strcmp(str, SCHED_DEF)==0) {
                        si->procAttr.schedClass = OS_SCHED_DEFAULT;
                    } else {
                        si->procAttr.schedClass = OS_SCHED_DEFAULT;
                        OS_REPORT_1(OS_WARNING, OSRPT_CNTXT_SPLICED, 
                             0, "Incorrect <Scheduling/Class> parameter for service %s -> default",
                             si->name);
                         r = TRUE;
                    }
                }
            }
            os_free(str);
        }
        u_cfDataFree(d);
    } else {
        si->procAttr.schedClass = OS_SCHED_DEFAULT;
        if (iterLength == 0) {
            OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
                0, "Taking default for <Scheduling/Class> parameter service %s", si->name);
        } else {
            OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
                0, "One <Scheduling/Class> parameter expected for service %s", si->name);
            r = FALSE;
        }
        while (d != NULL) {
            u_cfDataFree(d);
            d = u_cfData(c_iterTakeFirst(iter));
        }
    }
    c_iterFree(iter);

    return r;
}
コード例 #19
0
void
idl_constExpressionFree (
    idl_constExpression constExpression)
{
    while (c_iterLength (constExpression->operands)) {
	idl_operandFree (idl_operand(c_iterTakeFirst (constExpression->operands)));
    }
    c_iterFree (constExpression->operands);
}
コード例 #20
0
void
jni_getTopicKeyExpression(
    v_entity entity,
    c_voidp args)
{
    v_kernel vk;
    c_iter vtopics;
    c_array keyList;
    c_char* keyExpr;
    c_long nrOfKeys, totalSize, i;
    c_string fieldName, actualFieldName;
    struct jni_topicArg *arg;
    
    arg = (struct jni_topicArg *)args;
    vk = v_objectKernel(entity);
    
    if(vk != NULL){
        vtopics = v_resolveTopics(vk, arg->topicName);
            
        if(c_iterLength(vtopics) == 0){
            c_iterFree(vtopics);
        }
        else{
            keyList = v_topicMessageKeyList(c_iterTakeFirst(vtopics));
            c_iterFree(vtopics);                
            nrOfKeys = c_arraySize(keyList);

            if (nrOfKeys>0) {
                totalSize = 0;
                
                for (i=0;i<nrOfKeys;i++) {
                    fieldName = c_fieldName(keyList[i]);
                    totalSize += (strlen(fieldName)+1-9/*skip 'userdata.'*/);
                }
                keyExpr = (c_char *)os_malloc((size_t)(totalSize+1));
                keyExpr[0] = 0;
                
                for (i=0;i<nrOfKeys;i++) {
                    fieldName = c_fieldName(keyList[i]);
                    actualFieldName = c_skipUntil(fieldName, ".");
                    actualFieldName++; /*skip '.' */
                    os_strcat(keyExpr,actualFieldName);
                    
                    if (i<(nrOfKeys-1)) { 
                        os_strcat(keyExpr,","); 
                    }
                }
                arg->keyExpr = keyExpr;
            } else{
                /*No keys, do nothing.*/
            }
            arg->result = U_RESULT_OK;
        }
    }
}
コード例 #21
0
ファイル: sr_serviceInfo.c プロジェクト: diorahman/opensplice
static c_bool
cfgGetPriorityKind(
    sr_serviceInfo si,
    u_cfElement info)
{
    c_iter iter;
    int      iterLength;
    c_bool r;
    u_cfElement d;
    c_char * str;

    r = TRUE;
    iter = u_cfElementXPath(info, "Scheduling/Priority");
    iterLength = c_iterLength(iter);
    d = u_cfElement(c_iterTakeFirst(iter));
    if (iterLength == 1) {
        r = u_cfElementAttributeStringValue(d, ATTR_PRIOKIND, &str);

        if (r == TRUE) {
            if (strcmp(str, PRIOKIND_REL) == 0) {
                si->priorityKind = V_SCHED_PRIO_RELATIVE;
            } else {
                if (strcmp(str, PRIOKIND_ABS) == 0) {
                    si->priorityKind = V_SCHED_PRIO_ABSOLUTE;
                } else {
                    si->priorityKind = V_SCHED_PRIO_RELATIVE;
                    OS_REPORT_1(OS_WARNING, OSRPT_CNTXT_SPLICED, 
                         0, "Incorrect <Scheduling/Priority[@priority_kind]> attribute for service %s -> default",
                         si->name);
                     r = TRUE;
                }
            }
            os_free(str);
        }
        u_cfElementFree(d);
    } else {
        if (iterLength == 0) {
            si->priorityKind = V_SCHED_PRIO_RELATIVE;
            OS_REPORT_1(OS_INFO, OSRPT_CNTXT_SPLICED, 
                0, "Taking default for <Scheduling/Priority[@priority_kind]> parameter for  service %s", si->name);
        } else {
            OS_REPORT_1(OS_ERROR, OSRPT_CNTXT_SPLICED, 
                0, "One <Scheduling/Priority[@priority_kind]> parameter expected for service %s", si->name);
            r = FALSE;
        }
        while (d != NULL) {
            u_cfElementFree(d);
            d = u_cfElement(c_iterTakeFirst(iter));
        }
    }
    c_iterFree(iter);

    return r;
}
コード例 #22
0
ファイル: u_dispatcher.c プロジェクト: S73417H/opensplice
static void *
dispatch(
    void *o)
{
    u_dispatcher _this;
    v_observer claim;
    struct listenerExecArg arg;
    u_result result;

    _this = u_dispatcher(o);
    if (_this != NULL) {
        if (_this->startAction) {
            _this->startAction(_this, _this->actionData);
        }
        os_mutexLock(&_this->mutex);
        result = u_entityReadClaim(u_entity(_this), (v_entity*)(&claim));
        if(result == U_RESULT_OK) {
            assert(claim);
            while ((!(_this->event & V_EVENT_OBJECT_DESTROYED)) &&
                   (_this->listeners != NULL) &&
                   (c_iterLength(_this->listeners) > 0)) {

                os_mutexUnlock(&_this->mutex);
                _this->event = v_observerWait(claim);
                os_mutexLock(&_this->mutex);
                if (!(_this->event & V_EVENT_OBJECT_DESTROYED)) {
                    /* do not call listeners when  object is destroyed! */
                    arg.mask = 0;
                    arg.o = _this;
                    c_iterWalk(_this->listeners,
                               (c_iterWalkAction)listenerExecute,
                               &arg);
                }
            }
            _this->threadId = OS_THREAD_ID_NONE;
            result = u_entityRelease(u_entity(_this));
            if (result != U_RESULT_OK) {
                OS_REPORT(OS_ERROR, "u_dispatcher::dispatch", 0,
                          "Release observer failed.");
            }
        } else {
            OS_REPORT(OS_WARNING, "u_dispatcher::dispatch", 0,
                      "Failed to claim Dispatcher.");
        }
        os_mutexUnlock(&_this->mutex);
        if (_this->stopAction) {
            _this->stopAction(_this, _this->actionData);
        }
    } else {
        OS_REPORT(OS_ERROR, "u_dispatcher::dispatch", 0,
                  "No dispatcher specified.");
    }
    return NULL;
}
コード例 #23
0
ファイル: idl_stacDef.c プロジェクト: osrf/opensplice
void
idl_stacDefRestoreAll(
    idl_stacDef stacDef,
    c_iter replaceInfos)
{
    os_uint32 size;
    os_uint32 i;
    idl_stacDefReplaceInfo info;
    os_uint32 j;
    os_uint32 replacedMembersSize;

    assert(replaceInfos);

    if(stacDef)
    {

        size = c_iterLength (replaceInfos);
        for(i = 0; i < size; i++)
        {
            info = c_iterTakeFirst(replaceInfos);
            replacedMembersSize = c_iterLength(info->replacedMembers);
            assert(replacedMembersSize == (os_uint32)c_iterLength(info->replacedIndexes));
            for(j = 0; j < replacedMembersSize; j++)
            {
                os_uint32* index;
                c_member member;

                index = c_iterTakeFirst(info->replacedIndexes);
                member = c_iterTakeFirst(info->replacedMembers);

                info->structure->members[*index] = member;
                os_free(index);
            }
            c_iterFree(info->replacedMembers);
            c_iterFree(info->replacedIndexes);
            os_free(info);
        }
        c_iterFree(replaceInfos);
    }
}
コード例 #24
0
ファイル: cms_service.c プロジェクト: shizhexu/opensplice
cms_client
cms_serviceLookupClient(
    cms_service cms,
    struct soap* soap,
    const c_char* uri)
{
    int i;
    cms_client client;
    cms_client result;

    result = NULL;
    os_mutexLock(&cms->clientMutex);

    for(i=0; i<c_iterLength(cms->clients) && result == NULL; i++) {
        client = cms_client(c_iterObject(cms->clients, i));

        if(client->ip == soap->ip) {
            if(cms_thread(client)->terminate == FALSE) {
                result = client;
            }
        }
    }

    if( (result == NULL) &&
            (((c_ulong)c_iterLength(cms->clients)) < cms->configuration->maxClients))
    {
        result                  = cms_clientNew(soap->ip, cms, uri);
        cms->clients            = c_iterInsert(cms->clients, result);
        cms_clientStart(result);
        cms_serviceUpdateStatistics(cms);

        if(cms->configuration->verbosity >= 4) {
            OS_REPORT_4(OS_INFO, CMS_CONTEXT, 0,
                        "Client thread started for IP: %d.%d.%d.%d",
                        (int)(result->ip>>24)&0xFF,
                        (int)(result->ip>>16)&0xFF,
                        (int)(result->ip>>8)&0xFF,
                        (int)(result->ip&0xFF));
        }
コード例 #25
0
ファイル: q_expr.c プロジェクト: xrl/opensplice_dds
c_long
q_countVar(
    q_expr e)
{
    c_long nrOfVar;
    c_iter list;

    list = c_iterNew(NULL);
    q_countVarWalk(e,list);
    nrOfVar = c_iterLength(list);
    c_iterFree(list);
    return nrOfVar;
}
コード例 #26
0
char *
idl_constExpressionImage (
    idl_constExpression constExpression)
{
    char *image = NULL;
    char *operandImage = NULL;
    int i;
    int newLen;

    if (c_iterLength (constExpression->operands) == 1) {
	/* Unary operator */
	operandImage = idl_operandImage (idl_operand(c_iterObject (constExpression->operands, 0)));
	newLen = strlen (operatorImage(constExpression->kind)) + strlen (operandImage) + 3;
	image = os_malloc (newLen);
	snprintf (image, newLen, "(%s%s)", operatorImage(constExpression->kind), operandImage);
	os_free (operandImage);
    } else {
	/* Binary operator */
        for (i = 0; i < c_iterLength (constExpression->operands); i++) {
	    operandImage = idl_operandImage (idl_operand(c_iterObject (constExpression->operands, i)));
	    if (image == NULL) {
	        newLen = strlen (operandImage) + 2;
	        image = os_malloc (newLen);
	       os_strncpy (image, "(", newLen);
	    } else {
	        newLen = strlen (image) + strlen (operatorImage(constExpression->kind)) + strlen (operandImage) + 4;
	        image = os_realloc (image, newLen);
		strncat (image, " ", newLen);
	        os_strncat (image, operatorImage(constExpression->kind), newLen);
		strncat (image, " ", newLen);
	    }
	    os_strncat (image, operandImage, newLen);
	    os_free (operandImage);
        }
	strncat (image, ")", newLen);
    }
    return image;
}
コード例 #27
0
ファイル: v_partition.c プロジェクト: xrl/opensplice
c_iter
v_partitionLookupSubscribers(
    v_partition partition)
{
    c_iter participants;
    c_iter result;
    c_iter entities;
    c_iter partitions;
    v_participant participant;
    v_entity entity;
    v_entity partition2;

    result = NULL;
    participants = v_resolveParticipants(v_objectKernel(partition), "*");
    participant = v_participant(c_iterTakeFirst(participants));

    while (participant != NULL) {
        c_lockRead(&participant->lock);
        entities = c_select(participant->entities, 0);
        c_lockUnlock(&participant->lock);
        entity = v_entity(c_iterTakeFirst(entities));

        while (entity != NULL) {
            if(v_objectKind(entity) == K_SUBSCRIBER) {
                partitions = v_subscriberLookupPartitions(v_subscriber(entity),
                                                    v_partitionName(partition));

                if (c_iterLength(partitions) > 0) {
                    result = c_iterInsert(result, entity); /* transfer refcount */
                } else {
                    c_free(entity);
                }
                partition2 = v_entity(c_iterTakeFirst(partitions));

                while (partition2 != NULL) {
                    c_free(partition2);
                    partition2 = v_entity(c_iterTakeFirst(partitions));
                }
                c_iterFree(partitions);
            }
            /* entity is already free or refcount transferred to result */
            entity = v_entity(c_iterTakeFirst(entities));
        }
        c_iterFree(entities);
        c_free(participant);
        participant = v_participant(c_iterTakeFirst(participants));
    }
    c_iterFree(participants);
    return result;
}
コード例 #28
0
ファイル: idl_keyDef.c プロジェクト: xrl/opensplice_dds
/* Find the key list related to the specified typename in
   the specified scope
*/
c_char *
idl_keyResolve (
    idl_keyDef keyDef,
    idl_scope scope,
    const char *typeName)
{
    c_long li;
    c_long si;
    idl_keyMap keyMap;
    c_metaObject typeScope;

    li = 0;
    /* check all key definition list elements */
    while (li < c_iterLength (keyDef->keyList)) {
	keyMap = c_iterObject (keyDef->keyList, li);
	if (strcmp(typeName, keyMap->typeName) == 0) {
	    /* if the typename equals, check if the scope compares */
	    if ((idl_scopeStackSize(scope) == 0) && (keyMap->scope->definedIn == NULL)) {
		/* Global scope */
		return keyMap->keyList;
	    }
	    si = idl_scopeStackSize (scope)-1;
	    typeScope = keyMap->scope;
	    while (si >= 0) {
		/* for each scope element */
		if (idl_scopeElementType(idl_scopeIndexed (scope, si)) == idl_tModule &&
		    strcmp (typeScope->name, idl_scopeElementName(idl_scopeIndexed (scope, si))) == 0) {
		    /* the scope is a module and the scope name compares */
		    si--;
		    if (typeScope) {
			typeScope = typeScope->definedIn;
		    }
		    if (si == -1) {
			/* bottom of the stack is reached */
		        if (typeScope == NULL || typeScope->name == NULL) {
			    /* the typeScope has reached the bottom too,
			       thus the scopes are equal
			    */
			    return keyMap->keyList;
			}
		    }
		} else {
		    si = -1;
		}
	    }
	}
	li++;
    }
    return NULL;
}
コード例 #29
0
ファイル: d_waitset.c プロジェクト: xrl/opensplice_dds
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;
}
コード例 #30
0
ファイル: u_subscriber.c プロジェクト: diorahman/opensplice
c_long
u_subscriberReaderCount(
    u_subscriber _this)
{
    c_long length = -1;
    u_result result;

    result = u_entityLock(u_entity(_this));
    if (result == U_RESULT_OK) {
        length = c_iterLength(_this->readers);
        u_entityUnlock(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberRemoveReader",0,
                  "Failed to lock Subscriber.");
    }
    return length;
}