Ejemplo n.º 1
0
c_char*
cmx_participantAllDomains(
    const c_char* participant)
{
    u_result ur;
    cmx_walkEntityArg arg;
    c_char* result;
    cmx_entity ce;

    result = NULL;
    ce = cmx_entityClaim(participant);

    if(ce != NULL){
        arg = cmx_walkEntityArg(os_malloc(C_SIZEOF(cmx_walkEntityArg)));
        if (arg != NULL) {
            arg->length = 0;
            arg->list = NULL;
            arg->entityArg.entity = ce;
            arg->entityArg.create = TRUE;
            arg->entityArg.result = NULL;

            ur = u_observableAction(u_observable(ce->uentity),
                                    cmx_participantDomainsAction,
                                    (c_voidp)arg);
            if (ur == U_RESULT_OK) {
                result = cmx_convertToXMLList(arg->list, arg->length);
            }
            os_free(arg);
        }
        cmx_entityRelease(ce);
    }
    return result;
}
Ejemplo n.º 2
0
const c_char*
cmx_participantRegisterType(
    const c_char* participant,
    const c_char* type)
{
    sd_serializer serializer;
    sd_serializedData meta_data;
    cmx_entityKernelArg kernelArg;
    c_type topicType;
    cmx_entity ce;
    const c_char* result;
    const c_char* msg;

    ce = cmx_entityClaim(participant);
    if(ce != NULL){
        kernelArg = cmx_entityKernelArg(os_malloc(C_SIZEOF(cmx_entityKernelArg)));
        if (u_observableAction(u_observable(ce->uentity),
                               cmx_entityKernelAction,
                               (c_voidp)kernelArg) == U_RESULT_OK)
        {
            serializer = sd_serializerXMLMetadataNew(c_getBase(c_object(kernelArg->kernel)));

            if(serializer != NULL){
                meta_data = sd_serializerFromString(serializer, type);

                if (meta_data != NULL) {
                    topicType = c_type(sd_serializerDeserialize(serializer, meta_data));

                    if (topicType == NULL) {
                        msg = sd_serializerLastValidationMessage(serializer);
                        OS_REPORT(OS_ERROR,
                                  CM_XML_CONTEXT, 0,
                                  "Data type could not be registered, "
                                  "because it is not valid: %s",
                                  msg);
                        result = CMX_RESULT_FAILED;
                    } else {
                        result = CMX_RESULT_OK;
                    }
                    sd_serializedDataFree(meta_data);
                } else {
                    OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Construction of serialized data failed.");
                    result = CMX_RESULT_FAILED;
                }
                sd_serializerFree(serializer);
            } else {
                OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Serializer could not be initialized");
                result = CMX_RESULT_FAILED;
            }
        } else {
            OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Kernel object could not be retrieved");
            result = CMX_RESULT_FAILED;
        }
        os_free(kernelArg);
        cmx_entityRelease(ce);
    } else {
        result = CMX_RESULT_FAILED;
    }
    return result;
}
Ejemplo n.º 3
0
c_char*
cmx_readerSnapshotNew(
    const c_char* reader)
{
    cmx_entity ce;
    c_char* result;
    struct cmx_readerSnapshotArg arg;
    os_mutex m;

    arg.success = FALSE;
    result = NULL;

    ce = cmx_entityClaim(reader);
    if(ce != NULL){
        if (u_observableAction(u_observable(ce->uentity),
                               cmx_readerSnapshotNewAction,
                               &arg) == U_RESULT_OK)
        {
            if(arg.success == TRUE){
                m = cmx_getReaderSnapshotMutex();
                os_mutexLock(&m);
                readerSnapshots = c_iterInsert(readerSnapshots, arg.snapshot);
                os_mutexUnlock(&m);

                result = (c_char*)(os_malloc(60));
                os_sprintf(result,
                           "<readerSnapshot><id>"PA_ADDRFMT"</id></readerSnapshot>",
                           (c_address)(arg.snapshot));
            }
        }
        cmx_entityRelease(ce);
    }
    return result;
}
Ejemplo n.º 4
0
void
cms_clientFree(
    cms_client client)
{
    struct soap* soap;
    cms_soapThread soapThread;

    cms_thread(client)->terminate = TRUE;

    os_mutexLock(&client->conditionMutex);
    os_condSignal(&client->condition);
    os_mutexUnlock(&client->conditionMutex);

    cms_threadDeinit(cms_thread(client));

    if(client->soapEnvs){
        os_mutexLock(&client->soapMutex);
        soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs));

        while(soap){
            soap->error = soap_receiver_fault(soap, "Service is terminating.", NULL);
            soap_send_fault(soap);
            soap_destroy(soap);
            soap_end(soap);
            soap_done(soap);
            os_free(soap);
            soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs));
        }
        c_iterFree(client->soapEnvs);
        client->soapEnvs = NULL;
        os_mutexUnlock(&client->soapMutex);
    }

    if(client->threads){
        soapThread = cms_soapThread(c_iterTakeFirst(client->threads));

        while(soapThread){
            cms_soapThreadFree(soapThread);
            (void)u_observableAction(u_observable(client->service->uservice), cms_clientStatisticsThreadRemove, client->service);
            soapThread = cms_soapThread(c_iterTakeFirst(client->threads));
        }
        c_iterFree(client->threads);
        client->threads = NULL;
    }
    os_mutexDestroy(&client->soapMutex);
    os_mutexDestroy(&client->threadMutex);
    os_mutexDestroy(&client->conditionMutex);
    os_condDestroy(&client->condition);
    client->initCount = 0;

    if(client->service->configuration->verbosity >= 5){
        OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                        "Client thread stopped for IP: %d.%d.%d.%d",
                        (int)(client->ip>>24)&0xFF,
                        (int)(client->ip>>16)&0xFF,
                        (int)(client->ip>>8)&0xFF,
                        (int)(client->ip&0xFF));
    }
Ejemplo n.º 5
0
DDS::ReturnCode_t
DDS::OpenSplice::Utils::observableExists(
    u_observable observable)
{
    DDS::ReturnCode_t result;

    u_result uResult = u_observableAction(observable, &dummy_callback, NULL);
    result = DDS::OpenSplice::CppSuperClass::uResultToReturnCode(uResult);

    return result;
}
Ejemplo n.º 6
0
JNIEXPORT jint JNICALL
SAJ_FUNCTION(jniConditionIsAlive)(
    JNIEnv *env,
    jobject _this,
    jlong  uObject)
{
    int result = SAJ_RETCODE_ALREADY_DELETED;
    u_result uResult;

    OS_UNUSED_ARG(env);
    OS_UNUSED_ARG(_this);

    uResult = u_observableAction(u_observable(SAJ_VOIDP(uObject)), dummy_callback, NULL);
    result = saj_retcode_from_user_result(uResult);

    return result;
}
Ejemplo n.º 7
0
const c_char*
cmx_participantAutoDetach(
    const c_char* participant,
    c_bool enable)
{
    u_participant up;
    u_result result;
    cmx_entity ce;

    ce = cmx_entityClaim(participant);

    if (ce == NULL) {
        goto errorGetEntity;
    }
    up = u_participant(ce->uentity);
    if (enable == FALSE) {
        result = u_observableRemoveListener(u_observable(up), cmx_participantDetach);
        if (result != U_RESULT_OK) {
            goto errorRemoveListener;
        }
    } else {
        result = u_observableAction(u_observable(up), cmx_participantInitDetach, NULL);
        if (result != U_RESULT_OK) {
            goto errorEntityAction;
        }
        result = u_observableAddListener(u_observable(up),
                                         V_EVENT_SERVICESTATE_CHANGED,
                                         cmx_participantDetach,
                                         u_serviceManagerNew(up));
        if (result != U_RESULT_OK) {
            goto errorInsertListener;
        }
    }
    cmx_entityRelease(ce);

    return CMX_RESULT_OK;
    
errorInsertListener:
errorEntityAction:
errorRemoveListener:
errorGetEntity:
    return CMX_RESULT_FAILED;
}
Ejemplo n.º 8
0
void
SubscriberDelegate::reset_data_on_readers()
{
    u_result uResult;

    /* TODO: This is a bit tricky, the entity may already been deleted and in that case
    * this operation will perform a dirty memory read.
    * It may be better to wipe all pending events belonging to an entity when it is deleted or
    * if that is too intrusive find another way to safely detect/avoid deletion.
    * NOTE: This was copied from SAC.
    */
    uResult = u_observableAction(
                        u_observable(this->userHandle),
                        SubscriberDelegate::reset_data_on_readers_callback,
                        NULL);

    if (uResult != U_RESULT_OK) {
        ISOCPP_REPORT_WARNING("Could not reset data available status.");
    }
}
Ejemplo n.º 9
0
c_char*
cmx_serviceGetState(
    const c_char* service)
{
    cmx_entity ce;
    c_char* result;

    result = NULL;

    ce = cmx_entityClaim(service);

    if(ce != NULL){
        if (u_observableAction(u_observable(ce->uentity),
                               cmx_serviceActionGetState,
                               &result) != U_RESULT_OK)
        {
            result = NULL;
        }
        cmx_entityRelease(ce);
    }
    return result;
}
Ejemplo n.º 10
0
c_char*
cmx_participantFindTopic(
    const c_char* participant,
    const c_char* topicName)
{
    u_result ur;
    c_char* topics;
    cmx_walkEntityArg arg;
    cmx_entity ce;

    topics = NULL;

    ce = cmx_entityClaim(participant);

    if(ce != NULL){
        arg = cmx_walkEntityArg(os_malloc(C_SIZEOF(cmx_walkParticipantArg)));
        if (arg != NULL){
            arg->length = 0;
            arg->list = NULL;
            arg->entityArg.entity = ce;
            arg->entityArg.create = TRUE;
            arg->entityArg.result = NULL;
            cmx_walkParticipantArg(arg)->topicName = topicName;

            ur = u_observableAction(u_observable(ce->uentity),
                                    cmx_participantFindTopicAction,
                                    (c_voidp)arg);
            if (ur == U_RESULT_OK) {
                topics = cmx_convertToXMLList(arg->list, arg->length);
            }
            os_free(arg);
        }
        cmx_entityRelease(ce);
    }
    return topics;
}