Ejemplo n.º 1
0
u_subscriber
u_subscriberNew(
    u_participant p,
    const c_char *name,
    v_subscriberQos qos,
    c_bool enable)
{
    u_subscriber _this = NULL;
    v_subscriber ks;
    v_participant kp = NULL;
    u_result result;

    if (name == NULL) {
        name = "No name specified";
    }
    if (p != NULL) {
        result = u_entityWriteClaim(u_entity(p),(v_entity*)(&kp));
        if (result == U_RESULT_OK) {
            assert(kp);
            ks = v_subscriberNew(kp,name,qos,enable);
            if (ks != NULL) {
                _this = u_entityAlloc(p,u_subscriber,ks,TRUE);
                if (_this != NULL) {
                    result = u_subscriberInit(_this,p);
                    if (result != U_RESULT_OK) {
                        OS_REPORT_1(OS_ERROR, "u_subscriberNew", 0,
                                    "Initialisation failed. "
                                    "For DataReader: <%s>.", name);
                        (void)u_subscriberFree(_this);
                        _this = NULL;
                    }
                } else {
                    OS_REPORT_1(OS_ERROR, "u_subscriberNew", 0,
                                "Create user proxy failed. "
                                "For Subscriber: <%s>.", name);
                }
                c_free(ks);
            } else {
                OS_REPORT_1(OS_ERROR, "u_subscriberNew", 0,
                            "Create kernel entity failed. "
                            "For Subscriber: <%s>.", name);
            }
            result = u_entityRelease(u_entity(p));
            if (result != U_RESULT_OK) {
                OS_REPORT_1(OS_WARNING, "u_subscriberNew", 0,
                            "Could not release participant."
                            "However subscriber <%s> is created.", name);
            }
        } else {
            OS_REPORT_1(OS_WARNING, "u_subscriberNew", 0,
                        "Claim Participant failed. "
                        "For Subscriber: <%s>.", name);
        }
    } else {
        OS_REPORT_1(OS_ERROR,"u_subscriberNew",0,
                    "No Participant specified. "
                    "For Subscriber: <%s>", name);
    }
    return _this;
}
Ejemplo n.º 2
0
u_groupQueue
u_groupQueueNew(
    u_subscriber s,
    const c_char *name,
    c_ulong queueSize,
    v_readerQos qos)
{
    u_participant p;
    u_groupQueue _this = NULL;
    v_subscriber ks = NULL;
    v_groupQueue kn;
    u_result result;

    if (name != NULL) {
        if (s != NULL) {
            result = u_entityWriteClaim(u_entity(s),(v_entity*)(&ks));
            if (result == U_RESULT_OK) {
                assert(ks);
                kn = v_groupQueueNew(ks,name,queueSize,qos);
                if (kn != NULL) {
                    p = u_entityParticipant(u_entity(s));
                    _this = u_entityAlloc(p,u_groupQueue,kn,TRUE);
                    if (_this != NULL) {
                        result = u_groupQueueInit(_this,s);
                        if (result != U_RESULT_OK) {
                            OS_REPORT_1(OS_ERROR, "u_groupQueueNew", 0,
                                        "Initialisation failed. "
                                        "For groupQueue: <%s>.", name);
                            u_groupQueueFree(_this);
                        }
                    } else {
                        OS_REPORT_1(OS_ERROR, "u_groupQueueNew", 0,
                                    "Create proxy failed. "
                                    "For groupQueue: <%s>.", name);
                    }
                    c_free(kn);
                } else {
                    OS_REPORT_1(OS_ERROR, "u_groupQueueNew", 0,
                                "Create kernel entity failed. "
                                "For groupQueue: <%s>.", name);
                }
                result = u_entityRelease(u_entity(s));
            } else {
                OS_REPORT_2(OS_WARNING, "u_groupQueueNew", 0,
                            "Claim Subscriber (0x%x) failed. "
                            "For groupQueue: <%s>.", s, name);
            }
        } else {
            OS_REPORT_1(OS_ERROR,"u_groupQueueNew",0,
                        "No Subscriber specified. "
                        "For groupQueue: <%s>", name);
        }
    } else {
        OS_REPORT(OS_ERROR,"u_groupQueueNew",0,
                  "No name specified.");
    }
    return _this;
}
Ejemplo n.º 3
0
u_partition
u_partitionNew(
    u_participant p,
    const c_char *name,
    v_partitionQos qos)
{
    u_partition _this = NULL;
    v_kernel ke = NULL;
    v_partition kd;
    u_result result;

    if (name == NULL) {
        name = "No partition specified";
    }
    if (p != NULL) {
        result = u_entityWriteClaim(u_entity(u_participantDomain(p)),(v_entity*)(&ke));
        if ((result == U_RESULT_OK) && (ke != NULL)) {
            kd = v_partitionNew(ke,name,qos);
            if (kd != NULL) {
                _this = u_entityAlloc(p,u_partition,kd,FALSE);
                if (_this != NULL) {
                    result = u_partitionInit(_this);
                    if (result != U_RESULT_OK) {
                        OS_REPORT_1(OS_ERROR, "u_partitionNew", 0,
                                    "Initialisation failed. "
                                    "For Partition: <%s>.", name);
                        u_partitionFree(_this);
                    }
                } else {
                    OS_REPORT_1(OS_ERROR, "u_partitionNew", 0,
                                "Create proxy failed. "
                                "For Partition: <%s>.", name);
                }
                c_free(kd);
            } else {
                OS_REPORT_1(OS_ERROR, "u_partitionNew", 0,
                            "Create kernel entity failed. "
                            "For Partition: <%s>", name);
            }
            result = u_entityRelease(u_entity(u_participantDomain(p)));
        } else {
            OS_REPORT_1(OS_WARNING, "u_partitionNew", 0,
                        "Claim Participant failed. "
                        "For Partition: <%s>", name);
        }
    } else {
        OS_REPORT_1(OS_ERROR,"u_partitionNew",0,
                    "No Participant specified. "
                    "For Partition: <%s>", name);
    }
    return _this;
}
Ejemplo n.º 4
0
u_result
u_topicDisposeAllData (u_topic _this)
{
    v_topic topic;
    u_result result;
    v_result r;

    result = u_entityWriteClaim(u_entity(_this), (v_entity*)(&topic));
    if (result == U_RESULT_OK) {
        assert(topic);
        r = v_topicDisposeAllData(topic);
        u_entityRelease(u_entity(_this));
        result = u_resultFromKernel(r);
    }
    return result;
}
Ejemplo n.º 5
0
u_result
u_subscriberSubscribe(
    u_subscriber _this,
    const c_char *partitionExpr)
{
    v_subscriber ks = NULL;
    u_result result;

    result= u_entityWriteClaim(u_entity(_this),(v_entity*)(&ks));
    if (result == U_RESULT_OK) {
        assert(ks);
        v_subscriberSubscribe(ks,partitionExpr);
        result = u_entityRelease(u_entity(_this));
    } else {
        OS_REPORT(OS_WARNING, "u_subscriberSubscribe", 0,
                  "Could not claim subscriber.");
    }
    return result;
}
Ejemplo n.º 6
0
/**************************************************************
 * constructor/destructor
 **************************************************************/
u_service
u_serviceNew(
    const c_char *uri,
    c_long timeout,
    const c_char *name,
    const c_char *extendedStateName,
    u_serviceKind kind,
    v_qos qos)
{
    u_domain domain;
    v_kernel kk;
    v_service ks;
    v_serviceManager sm;
    u_service s;
    u_result r;
    os_result osr;
    c_bool serviceTermHandlerRequired = FALSE;

    ks = NULL;
    r = u_domainOpen(&domain, uri, timeout);
    if (r != U_RESULT_OK) {
        OS_REPORT_1(OS_ERROR,"u_serviceNew",0,
                  "Failure to open the kernel - return code %d", r);
        return NULL;
    }

    s = NULL;
    if (domain != NULL) {
        r = u_entityWriteClaim(u_entity(domain),(v_entity*)(&kk));
        if (r == U_RESULT_OK) {
            assert(kk);
            sm = v_getServiceManager(kk);
            if (sm != NULL) {
#ifndef INTEGRITY
                if (lockPages(kk, name)) {
                    osr = os_procMLockAll(OS_MEMLOCK_CURRENT|OS_MEMLOCK_FUTURE);
                } else {
                    osr = os_resultSuccess;
                }
                if (osr == os_resultSuccess) {
#endif
                    switch(kind){
                    case U_SERVICE_DDSI:
                    case U_SERVICE_DDSIE:
                    case U_SERVICE_NETWORKING:
                        ks = v_service(v_networkingNew(sm, name,
                                                       extendedStateName,
                                                       (v_participantQos)qos));
                        serviceTermHandlerRequired = TRUE;
                    break;
                    case U_SERVICE_DURABILITY:
                        ks = v_service(v_durabilityNew(sm, name,
                                                       extendedStateName,
                                                       (v_participantQos)qos));
                        serviceTermHandlerRequired = TRUE;
                    break;
                    case U_SERVICE_CMSOAP:
                        ks = v_service(v_cmsoapNew(sm, name,
                                                   extendedStateName,
                                                   (v_participantQos)qos));
                        serviceTermHandlerRequired = TRUE;
                    break;
                    case U_SERVICE_RNR:
                        ks = v_service(v_rnrNew(sm, name,
                                                extendedStateName,
                                                (v_participantQos)qos));
                        serviceTermHandlerRequired = TRUE;
                    break;
                    case U_SERVICE_DBMSCONNECT:
                    case U_SERVICE_INCOGNITO:
                        ks = v_serviceNew(sm, name,
                                          extendedStateName,
                                          (v_participantQos)qos, NULL);
                        serviceTermHandlerRequired = TRUE;
                    break;
                    case U_SERVICE_SPLICED:
                    break;
                    default:
                        OS_REPORT(OS_WARNING,"u_serviceNew",0,
                                  "Failed to start an unknown service kind");
                    break;
                    }
                } else {
                    OS_REPORT(OS_ERROR,"u_serviceNew",0,
                              "Failed to lock memory pages for current process");
                }

                /* Install the service signal handlers if spliced is not within this
                 * same process.  i.e. only do this if each service is in its own
                 * process so signal handlers won't interfere */
                if (serviceTermHandlerRequired && !u_splicedInProcess()) {
                    os_procSetTerminationHandler(serviceTermHandler);
                }

#ifndef INTEGRITY

            } else {
                OS_REPORT(OS_ERROR,"u_serviceNew",0,
                          "Failed to retrieve the Service Manager");
            }
#endif
            if (ks != NULL) {
                s = u_entityAlloc(NULL,u_service,ks,TRUE);
                r = u_serviceInit(s, kind, domain);
                if (r != U_RESULT_OK) {
                    OS_REPORT_1(OS_ERROR,"u_serviceNew",0,
                                "Failed to initialize service: %s", name);
                    u_serviceFree(s);
                    s = NULL;
                }
                callbackService = s;
                (void) os_signalHandlerSetExceptionCallback(u__serviceExceptionCallbackWrapper);
            } else {
                OS_REPORT(OS_WARNING,"u_serviceNew",0,
                          "Failed to retrieve the Service Manager");
            }
            r = u_entityRelease(u_entity(domain));
        }
    }
    return s;
}
Ejemplo n.º 7
0
u_group
u_groupNew(
    u_participant participant,
    const c_char *partitionName,
    const c_char *topicName,
    v_duration timeout)
{
    u_result r;
    v_participant kparticipant;
    v_kernel kernel;
    v_topic ktopic;
    v_partition kpartition;
    v_group kgroup;
    c_iter topics;
    os_time delay;
    u_group group = NULL;

    if ((partitionName != NULL) && (topicName != NULL)) {
        if (participant != NULL) {
            r = u_entityWriteClaim(u_entity(participant), (v_entity*)(&kparticipant));
            if (r == U_RESULT_OK){
                assert(kparticipant);
                kernel = v_objectKernel(kparticipant);
                topics = v_resolveTopics(kernel,topicName);
                if (c_iterLength(topics) == 0) {
                    c_iterFree(topics);
                    delay.tv_sec = timeout.seconds;
                    delay.tv_nsec = timeout.nanoseconds;
                    os_nanoSleep(delay);
                    topics = v_resolveTopics(v_objectKernel(kparticipant),
                                             topicName);
                }
                if (c_iterLength(topics) > 1) {
                    OS_REPORT_1(OS_WARNING, "u_groupNew", 0,
                                "Internal error: "
                                "Multiple topics found with name = <%s>.",
                                topicName);
                }

                ktopic = c_iterTakeFirst(topics);

                /* If ktopic == NULL, the topic definition is unknown.
                 * This is not critical since it may become known in the near future.
                 * In that case the caller is responsible for retrying to create this group,
                 * and log something if, eventually, the group still cannot be created.
                 */
                if (ktopic != NULL) {
                    kpartition = v_partitionNew(kernel, partitionName, NULL);
                    if (kpartition != NULL) {
                        kgroup = v_groupSetCreate(kernel->groupSet, kpartition, ktopic);
                        if (kgroup != NULL) {
                            group = u_groupCreate(kgroup, participant);
                            if (group == NULL) {
                                OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                                            "Create proxy failed. "
                                            "For Partition <%s> and Topic <%s>.",
                                            partitionName, topicName);
                            }
                            c_free(kgroup);
                        } else {
                            OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                                        "Create kernel entity failed. "
                                        "For Partition <%s> and Topic <%s>.",
                                        partitionName, topicName);
                        }
                        c_free(kpartition);
                    } else {
                        OS_REPORT_2(OS_ERROR,"u_groupNew", 0,
                                    "Failed to create partition. "
                                    "For Partition <%s> and Topic <%s>.",
                                    partitionName, topicName);
                    }
                    c_free(ktopic);
                }
                ktopic = c_iterTakeFirst(topics);
                while (ktopic != NULL) {
                    c_free(ktopic);
                    ktopic = c_iterTakeFirst(topics);
                }
                c_iterFree(topics);
                r = u_entityRelease(u_entity(participant));
            } else {
                OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                            "Claim kernel participant failed."
                            "For Partition <%s> and Topic <%s>.",
                            partitionName, topicName);
            }
        } else {
            OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                        "No participant specified. "
                        "For Partition <%s> and Topic <%s>.",
                        partitionName, topicName);
        }
    } else {
        OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                    "Illegal parameter."
                    "partitionName = <0x%x>, topicName = <0x%x>.",
                    partitionName, topicName);
    }
    return group;
}
Ejemplo n.º 8
0
u_group
u_groupNew(
    u_participant participant,
    const c_char *partitionName,
    const c_char *topicName,
    v_duration timeout)
{
    u_result r;
    v_participant kparticipant;
    v_kernel kernel;
    v_topic ktopic;
    v_partition kpartition;
    v_group kgroup;
    c_iter topics;
    os_time delay;
    u_group group = NULL;

    if ((partitionName != NULL) && (topicName != NULL)) {
        if (participant != NULL) {
            r = u_entityWriteClaim(u_entity(participant), (v_entity*)(&kparticipant));
            if (r == U_RESULT_OK){
                assert(kparticipant);
                kernel = v_objectKernel(kparticipant);
                topics = v_resolveTopics(kernel,topicName);
                if (c_iterLength(topics) == 0) {
                    c_iterFree(topics);
                    delay.tv_sec = timeout.seconds;
                    delay.tv_nsec = timeout.nanoseconds;
                    os_nanoSleep(delay);
                    topics = v_resolveTopics(v_objectKernel(kparticipant),
                                             topicName);
                }
                if (c_iterLength(topics) > 1) {
                    OS_REPORT_1(OS_WARNING, "u_groupNew", 0,
                                "Internal error: "
                                "Multiple topics found with name = <%s>.",
                                topicName);
                }
                ktopic = c_iterTakeFirst(topics);
                if (ktopic != NULL) {
                    kpartition = v_partitionNew(kernel, partitionName, NULL);
                    if (kpartition != NULL) {
                        kgroup = v_groupSetCreate(kernel->groupSet, kpartition, ktopic);
                        if (kgroup != NULL) {
                            group = u_groupCreate(kgroup, participant);
                            if (group == NULL) {
                                OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                                            "Create proxy failed. "
                                            "For Partition <%s> and Topic <%s>.",
                                            partitionName, topicName);
                            }
                            c_free(kgroup);
                        } else {
                            OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                                        "Create kernel entity failed. "
                                        "For Partition <%s> and Topic <%s>.",
                                        partitionName, topicName);
                        }
                        c_free(kpartition);
                    } else {
                        OS_REPORT_2(OS_ERROR,"u_groupNew", 0,
                                    "Failed to create partition. "
                                    "For Partition <%s> and Topic <%s>.",
                                    partitionName, topicName);
                    }
                    c_free(ktopic);
                }else {
                    OS_REPORT_2(OS_ERROR,"u_groupNew", 0,
                                    "Topic not (yet) known. "
                                    "For Partition <%s> and Topic <%s>.",
                                    partitionName, topicName);
                }
                ktopic = c_iterTakeFirst(topics);
                while (ktopic != NULL) {
                    c_free(ktopic);
                    ktopic = c_iterTakeFirst(topics);
                }
                c_iterFree(topics);
                r = u_entityRelease(u_entity(participant));
            } else {
                OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                            "Claim kernel participant failed."
                            "For Partition <%s> and Topic <%s>.",
                            partitionName, topicName);
            }
        } else {
            OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                        "No participant specified. "
                        "For Partition <%s> and Topic <%s>.",
                        partitionName, topicName);
        }
    } else {
        OS_REPORT_2(OS_ERROR,"u_groupNew",0,
                    "Illegal parameter."
                    "partitionName = <0x%x>, topicName = <0x%x>.",
                    partitionName, topicName);
    }
    return group;
}
Ejemplo n.º 9
0
u_topic
u_topicNew(
    u_participant p,
    const c_char *name,
    const c_char *typeName,
    const c_char *keyList,
    v_topicQos qos)
{
    u_topic _this = NULL;
    v_topic kt;
    v_kernel kk;
    u_result result;

    if (name != NULL) {
        if (p != NULL) {
            result = u_entityWriteClaim(u_entity(p->domain),(v_entity*)(&kk));
            if (result == U_RESULT_OK) {
                assert(kk);
                kt = v_topicNew(kk,name,typeName,keyList,qos);
                if (kt != NULL) {
                    _this = u_entityAlloc(p,u_topic,kt,FALSE);
                    if (_this != NULL) {
                      /* This call is moved to u_entityNew to support
                       * proxy Topics. This move does not comply with
                       * the constructor pattern used by all other
                       * Entities, so this need to be fixed.
                       *
                    result = u_topicInit(_this,name,p);
                       */

                        if (result == U_RESULT_OK) {
                            v_entitySetUserData(v_entity(kt), _this);
                        } else {
                            OS_REPORT_1(OS_ERROR, "u_topicNew", 0,
                                        "Initialisation failed. "
                                        "For Topic: <%s>", name);
                            u_topicFree(_this);
                        }
                    } else {
                        OS_REPORT_1(OS_ERROR, "u_topicNew", 0,
                                    "Create user proxy failed. "
                                    "For Topic: <%s>", name);
                    }
                    c_free(kt);
                } else {
                    OS_REPORT_1(OS_WARNING, "u_topicNew", 0,
                                "Create kernel entity failed. "
                                "For Topic: <%s>", name);
                }
                result = u_entityRelease(u_entity(p->domain));
            } else {
                OS_REPORT_1(OS_WARNING, "u_topicNew", 0,
                            "Claim Kernel failed. "
                            "For Topic: <%s>", name);
            }
        } else {
            OS_REPORT_1(OS_ERROR,"u_topicNew",0,
                        "No Participant specified. "
                        "For Topic: <%s>", name);
        }
    } else {
        OS_REPORT(OS_ERROR,"u_topicNew",0,
                  "No name specified.");
    }
    return _this;
}