Example #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;
}
Example #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;
}
Example #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;
}
Example #4
0
/* To be called from protected threads only */
u_group
u_groupCreate(
    v_group group,
    u_participant participant)
{
    u_group _this;

    if (group != NULL) {
        /* Create u_entity. We are not the owner of the handle */
        _this = u_entityAlloc(participant, u_group, group, FALSE);
    } else {
        _this = NULL;
    }

    return _this;
}
Example #5
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;
}
Example #6
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;
}