Пример #1
0
void
v_handleServerResume(
    v_handleServer server)
{
    if (server == NULL) {
        OS_REPORT(OS_ERROR,"Kernel HandleServer",0,
                           "v_handleServerResume: no server specified");
    } else {
        server->suspended = FALSE;
        OS_REPORT(OS_WARNING,"Kernel HandleServer",0,"v_handleServer is resumed.");
    }
}
Пример #2
0
void
v_handleServerSuspend(
    v_handleServer server)
{
    if (server == NULL) {
        OS_REPORT(OS_ERROR,"Kernel HandleServer",0,
                           "v_handleServerSuspend: no server specified");
    } else {
        server->suspended = TRUE;
        OS_REPORT(OS_WARNING,"Kernel HandleServer",0,"v_handleServer is suspended.");
    }
}
Пример #3
0
c_long
v_handleServerClaims(
    v_handleServer server)
{
    if (server == NULL) {
        OS_REPORT(OS_ERROR,"Kernel HandleServer",0,
                           "v_handleServerClaims: no server specified");
    }
    OS_REPORT(OS_WARNING,"Kernel HandleServer",0,
              "v_handleServerClaims not yet implemented");
    return 0;
}
Пример #4
0
u_topic
u_topicNew(
    const u_participant p,
    const os_char *name,
    const os_char *typeName,
    const os_char *keyList,
    u_topicQos qos)
{
    u_topic _this = NULL;
    v_topicAdapter kt;
    v_participant kp;
    u_result result;

    assert(name != NULL);
    assert(typeName != NULL);
    assert(p != NULL);

    result = u_observableWriteClaim(u_observable(p),(v_public *)(&kp), C_MM_RESERVATION_HIGH);
    if (result == U_RESULT_OK) {
        assert(kp);
        kt = v_topicAdapterNew(kp,name,typeName,keyList,qos);
        if (kt != NULL) {
            _this = u_objectAlloc(sizeof(*_this), U_TOPIC, u__topicDeinitW, u__topicFreeW);
            if (_this != NULL) {
                result = u_topicInit(_this,name,kt,p);
                if (result != U_RESULT_OK) {
                    OS_REPORT(OS_ERROR, "u_topicNew", result,
                                "Initialisation failed. "
                                "For Topic: <%s>", name);
                    u_objectFree (u_object (_this));
                    _this = NULL;
                }
            } else {
                OS_REPORT(OS_ERROR, "u_topicNew", U_RESULT_OUT_OF_MEMORY,
                            "Create user proxy failed. "
                            "For Topic: <%s>", name);
            }
            c_free(kt);
        } else {
            OS_REPORT(OS_WARNING, "u_topicNew", U_RESULT_OUT_OF_MEMORY,
                        "Create kernel entity failed. "
                        "For Topic: <%s>", name);
        }
        u_observableRelease(u_observable(p), C_MM_RESERVATION_HIGH);
    } else {
        OS_REPORT(OS_WARNING, "u_topicNew", U_RESULT_INTERNAL_ERROR,
                    "Claim Kernel failed. "
                    "For Topic: <%s>", name);
    }
    return _this;
}
Пример #5
0
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;
}
Пример #6
0
u_result
u_dispatcherInsertListener(
    u_dispatcher _this,
    u_dispatcherListener listener,
    c_voidp userData)
{
    u_listener ul;
    os_threadAttr attr;
    v_observer ke;
    u_result result = U_RESULT_OK;
    c_char *name;

    if ((_this != NULL) && (listener != NULL)) {
        os_mutexLock(&_this->mutex);
        ul = u_listenerNew(listener,userData);
        _this->listeners = c_iterInsert(_this->listeners,ul);

        if (os_threadIdToInteger(_this->threadId) == 0U) {
            result = u_entityReadClaim(u_entity(_this), (v_entity*)(&ke));
            if(result == U_RESULT_OK) {
                assert(ke);
                name = v_entityName(ke);
                if (name == NULL) {
                    name = "NoName";
                }
                os_threadAttrInit(&attr);
                os_threadCreate(&_this->threadId,
                                name,
                                &attr,dispatch,
                                (void *)_this);
                result = u_entityRelease(u_entity(_this));
                if (result != U_RESULT_OK) {
                    OS_REPORT(OS_ERROR, "u_dispatcherInsertListener", 0,
                              "Release observer failed.");
                }
            } else {
                OS_REPORT(OS_WARNING, "u_dispatcherInsertListener", 0,
                          "Failed to claim Dispatcher.");
            }
        }
        u_entityEnable(u_entity(_this));
        os_mutexUnlock(&_this->mutex);
    } else {
        OS_REPORT(OS_ERROR,"u_dispatcherInsertListener",0,
                  "Illegal parameter.");
        result = U_RESULT_ILL_PARAM;
    }

    return result;
}
Пример #7
0
static u_result
u__waitsetDeinitW(
    void *_vthis)
{
    u_waitset _this;
    u_waitsetEntry entry;
    u_result result = U_RESULT_OK;

    _this = u_waitset(_vthis);
    os_mutexLock(&_this->mutex);

    _this->alive = FALSE;
    while (_this->waitBusy) {
        waitset_notify(_this, NULL);
        os_condWait(&_this->waitCv, &_this->mutex);
    }
    entry = c_iterTakeFirst(_this->entries);
    while (entry != NULL) {
        u_domain domain = u_observableDomain(u_observable(entry));
        result = u_domainRemoveWaitset(domain, _this);
        if (result != U_RESULT_OK) {
            OS_REPORT(OS_ERROR,
                      "u__waitsetDeinitW", result,
                      "Operation u_domainRemoveWaitset failed: "
                      "Waitset = 0x%"PA_PRIxADDR", result = %s",
                      (os_address)_this, u_resultImage(result));
            assert(FALSE);
        }
        result = u_objectFree_s(entry);
        if (result == U_RESULT_ALREADY_DELETED) {
            result = U_RESULT_OK;
        } else if (result != U_RESULT_OK) {
            OS_REPORT(OS_ERROR,
                      "u__waitsetDeinitW", result,
                      "Operation u_waitsetEntryFree failed: "
                      "Waitset = 0x%"PA_PRIxADDR", result = %s",
                      (os_address)_this, u_resultImage(result));
            result = U_RESULT_OK;
            (void)result;
            assert(FALSE);
        }
        entry = c_iterTakeFirst(_this->entries);
    }
    c_iterFree(_this->entries);
    _this->entries = NULL;

    os_mutexUnlock(&_this->mutex);
    u__objectDeinitW(_this);
    return result;
}
Пример #8
0
c_bool
v_serviceChangeState(
    v_service service,
    v_serviceStateKind newState)
{
    c_bool result;

    assert(service != NULL);
    assert(C_TYPECHECK(service, v_service));
    assert(service->state != NULL);
    assert(C_TYPECHECK(service->state, v_serviceState));

    result = v_serviceStateChangeState(service->state, newState);
    if(result)
    {
        switch(newState)
        {
            case STATE_OPERATIONAL:
                OS_REPORT(OS_INFO, "v_serviceChangeState", 0,
                    "++++++++++++++++++++++++++++++++++++++++++++++++" OS_REPORT_NL
                    "++ The service '%s' is now operational. " OS_REPORT_NL
                    "++++++++++++++++++++++++++++++++++++++++++++++++",
                    v_serviceGetName(service));
                break;
            case STATE_TERMINATED:
                OS_REPORT(OS_INFO, "v_serviceChangeState", 0,
                    "================================================" OS_REPORT_NL
                    "== The service '%s' has now terminated. "OS_REPORT_NL
                    "================================================",
                    v_serviceGetName(service));
                break;
            case STATE_DIED:
                OS_REPORT(OS_INFO, "v_serviceChangeState", 0,
                    "================================================" OS_REPORT_NL
                    "== The service '%s' has died. "OS_REPORT_NL
                    "================================================",
                    v_serviceGetName(service));
                break;
            case STATE_NONE:
            case STATE_INITIALISING:
            case STATE_TERMINATING:
            case STATE_INCOMPATIBLE_CONFIGURATION:
            default:
                /* ignore */
                break;
        }
    }
    return result;
}
Пример #9
0
u_result
u_waitsetDetachFromDomain(
    _Inout_ u_waitset _this,
    _Inout_ u_domain domain)
{
    u_result result;
    os_result osr;
    u_waitsetEntry entry;

    assert(_this != NULL);
    assert(domain != NULL);

    osr = os_mutexLock_s(&_this->mutex);
    if (osr == os_resultSuccess) {
        entry = c_iterResolve(_this->entries, compare_domain, domain);
        if (entry != NULL) {
            _this->notifyDetached = OS_TRUE;
            result = u_objectClose(entry);
            if (result == U_RESULT_ALREADY_DELETED) {
                result = U_RESULT_OK;
            }
            if (result == U_RESULT_OK) {
                /* The entry is already freed but the address value can still
                 * be used to update the administration because it only removes
                 * the address value from the list.
                 */
                c_iterTake(_this->entries, entry);
            } else {
                result = U_RESULT_INTERNAL_ERROR;
                OS_REPORT(OS_ERROR,
                            "u_waitsetDetachFromDomain", result,
                            "Operation u_waitsetEntryFree failed: "
                            "Waitset = 0x%"PA_PRIxADDR", result = %s",
                             (os_address)_this, u_resultImage(result));
                assert(FALSE);
            }
        } else {
            result = U_RESULT_PRECONDITION_NOT_MET;
        }
        (void)u_domainRemoveWaitset(domain, _this);
        os_mutexUnlock(&_this->mutex);
    } else {
        result = U_RESULT_INTERNAL_ERROR;
        OS_REPORT(OS_WARNING, "u_waitsetDetachFromDomain", result,
                  "Could not claim waitset.");
    }

    return result;
}
Пример #10
0
/** \brief Create a named shared memory area based upon
 *         POSIX shared memory object
 *
 * \b os_posix_sharedMemoryCreate gets a database file name for \b name
 * by calling \b os_posix_getShmObjName.
 *
 * When the file already exists, an error is returned.
 * Otherwise the file is created with \b shm_open and it's size is set according
 * the required database size by calling \b ftruncate.
 *
 * User credentials are taken into account by setting the correct ownership
 * by calling \b chown.
 */
os_result
os_posix_sharedMemoryCreate (
    const char *name,
    os_sharedAttr *sharedAttr,
    os_address size)
{
    char *shmname;
    int shmfd;
    os_result rv = os_resultSuccess;

    assert (name != NULL);
    assert (sharedAttr != NULL);
    /* roundup to page boundaries */
    shmname = os_posix_getShmObjName (name, sharedAttr->map_address, size, name);
    if (shmname != NULL) {
        shmfd = shm_open (shmname, O_CREAT | O_RDWR | O_EXCL, OS_PERMISSION);
        if (shmfd == -1) {
            OS_REPORT (OS_WARNING, "os_posix_sharedMemoryCreate", 1, "shm_open failed with error %d (%s)", os_getErrno(), name);
            rv = os_resultFail;
        } else {
#ifdef INTEGRITY
        if ( size % getpagesize() != 0 ) { 
            size += getpagesize() - ( size % getpagesize() );
        }
#endif
            if (ftruncate (shmfd, size) == -1) {
                OS_REPORT (OS_ERROR, "os_posix_sharedMemoryCreate", 1,
                    "ftruncate failed with error %d (%s)", os_getErrno(), name);
                close (shmfd);
                rv = os_resultFail;
            } else {
                if (sharedAttr->userCred.uid != 0 && sharedAttr->userCred.gid != 0) {
                    if (getuid() == 0 || geteuid() == 0) {
                        if (chown (shmname, sharedAttr->userCred.uid, sharedAttr->userCred.gid) == -1) {
                            OS_REPORT (OS_WARNING, "os_posix_sharedMemoryCreate", 1,
                                "chown failed with error %d (%s)", os_getErrno(), name);
                        }
                    } else {
                        OS_REPORT (OS_WARNING, "os_posix_sharedMemoryCreate", 2,
                            "Can not change ownership because of privilege problems (%s)", name);
                    }
                }
            }
        }
        close (shmfd);
        os_free (shmname);
    }
    return rv;
}
DDS::TopicDescription_ptr
DDS::DomainParticipant_impl::unprotected_lookup_topicdescription (
  const char * name
)
{
  gapi_topic handle;
  DDS::ccpp_UserData_ptr myUD;
  DDS::TopicDescription_ptr result = NULL;

  handle = gapi_domainParticipant_lookup_topicdescription(_gapi_self, name);

  if (handle)
  {
    myUD = dynamic_cast<DDS::ccpp_UserData_ptr>((DDS::Object *)gapi_object_get_user_data(handle));
    if (myUD)
    {
      result = dynamic_cast<DDS::TopicDescription_impl_ptr>(myUD->ccpp_object);
      if (result)
      {
        DDS::TopicDescription::_duplicate(result);
      }
      else
      {
        OS_REPORT(OS_ERROR, "CCPP", 0, "Invalid Topic Description");
      }
    }
    else
    {
      // If handle is found in GAPI, but has no UserData, then it has to be a builtin Topic.
      // That's how we know that a Topic_impl wrapper needs to be instantiated in this case.
      result = new DDS::Topic_impl(handle);
      if (result)
      {
        DDS::ccpp_UserData_ptr myUD;
        myUD = new DDS::ccpp_UserData(result, NULL);
        if (myUD)
        {
          gapi_object_set_user_data(handle, (DDS::Object *)myUD,
                                    ccpp_CallBack_DeleteUserData,NULL);
        }
        else
        {
          OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to allocate memory");
        }
      }
    }
  }
  return result;
}
Пример #12
0
d_groupInfo
d_groupInfoNew (
    const d_storeMMFKernel kernel,
    const d_topicInfo topic,
    const d_group dgroup)
{
    d_groupInfo group;
    c_base base;
    c_char* partition;
    c_type instanceType, groupInfoType;
    c_char *keyExpr;

    if(kernel && topic && dgroup){
        base = c_getBase(kernel);
        groupInfoType = c_resolve(base,"durabilityModule2::d_groupInfo");
        group = d_groupInfo(c_new(groupInfoType));
        c_free(groupInfoType);

        if (group) {
            group->kernel = kernel; /* Unmanaged pointer */
            group->topic = c_keep(topic);

            partition = d_groupGetPartition(dgroup);
            group->partition = c_stringNew(base, partition);
            os_free(partition);

            group->quality = d_groupGetQuality(dgroup);
            group->completeness = d_groupGetCompleteness(dgroup);

            instanceType = d_topicInfoGetInstanceType(topic);
            keyExpr = d_topicInfoGetInstanceKeyExpr(topic);
            group->instances = c_tableNew(instanceType, keyExpr);
            c_free(keyExpr);
            c_free(instanceType);
        } else {
            OS_REPORT(OS_ERROR,
                      "d_groupInfoNew",0,
                      "Failed to allocate d_groupInfo.");
            assert(FALSE);
            group = NULL;
        }
    } else {
        OS_REPORT(OS_ERROR,
                  "d_groupInfoNew",0,
                  "Illegal constructor parameter.");
        group = NULL;
    }
    return group;
}
Пример #13
0
u_topic
u_topicNewFromTopicInfo(
    u_participant p,
    const struct v_topicInfo *info,
    c_bool announce)
{
    u_topic _this = NULL;
    v_topicAdapter kt;
    v_participant kp;
    u_result result;

    assert (p);
    assert (info);

    result = u_observableWriteClaim(u_observable(p),(v_public*)(&kp), C_MM_RESERVATION_LOW);
    if (result == U_RESULT_OK) {
        assert(kp);
        kt = v_topicAdapterNewFromTopicInfo(kp,info,announce);
        if (kt != NULL) {
            _this = u_objectAlloc(sizeof(*_this), U_TOPIC, u__topicDeinitW, u__topicFreeW);
            if (_this != NULL) {
                result = u_topicInit(_this,info->name,kt,p);
                if (result != U_RESULT_OK) {
                    OS_REPORT(OS_ERROR, "u_topicNew", result,
                                "Initialisation failed. "
                                "For Topic: <%s>", info->name);
                    u_objectFree (u_object (_this));
                    _this = NULL;
                }
            } else {
                OS_REPORT(OS_ERROR, "u_topicNew", U_RESULT_OUT_OF_MEMORY,
                            "Create user proxy failed. "
                            "For Topic: <%s>", info->name);
            }
            c_free(kt);
        } else {
            OS_REPORT(OS_WARNING, "u_topicNewFromTopicInfo", U_RESULT_OUT_OF_MEMORY,
                      "Create kernel entity failed. "
                      "For Topic: <%s>", info->name);
        }
        u_observableRelease(u_observable(p),C_MM_RESERVATION_LOW);
    } else {
        OS_REPORT(OS_WARNING, "u_topicNewFromTopicInfo", U_RESULT_INTERNAL_ERROR,
                  "Claim Kernel failed. "
                  "For Topic: <%s>", info->name);
    }
    return _this;
}
c_bool
__chromatic_imap_dds_chromatic_imap_command__copyIn(
    c_base base,
    struct ::chromatic_imap_dds::chromatic_imap_command *from,
    struct _chromatic_imap_dds_chromatic_imap_command *to)
{
    c_bool result = OS_C_TRUE;
    (void) base;

    to->session_idx = (c_long)from->session_idx;
    to->locale_idx = (c_long)from->locale_idx;
#ifdef OSPL_BOUNDS_CHECK
    if(from->moniker){
        to->moniker = c_stringNew(base, from->moniker);
    } else {
        OS_REPORT (OS_ERROR, "copyIn", 0,"Member 'chromatic_imap_dds::chromatic_imap_command.moniker' of type 'c_string' is NULL.");
        result = OS_C_FALSE;
    }
#else
    to->moniker = c_stringNew(base, from->moniker);
#endif
#ifdef OSPL_BOUNDS_CHECK
    if(from->command){
        if(((unsigned int)strlen(from->command)) <= 32){
            to->command = c_stringNew(base, from->command);
        } else {
            OS_REPORT (OS_ERROR, "copyIn", 0,"Member 'chromatic_imap_dds::chromatic_imap_command.command' of type 'C_STRING<32>' is out of range.");
            result = OS_C_FALSE;
        }
    } else {
        OS_REPORT (OS_ERROR, "copyIn", 0,"Member 'chromatic_imap_dds::chromatic_imap_command.command' of type 'C_STRING<32>' is NULL.");
        result = OS_C_FALSE;
    }
#else
    to->command = c_stringNew(base, from->command);
#endif
#ifdef OSPL_BOUNDS_CHECK
    if(from->payload){
        to->payload = c_stringNew(base, from->payload);
    } else {
        OS_REPORT (OS_ERROR, "copyIn", 0,"Member 'chromatic_imap_dds::chromatic_imap_command.payload' of type 'c_string' is NULL.");
        result = OS_C_FALSE;
    }
#else
    to->payload = c_stringNew(base, from->payload);
#endif
    return result;
}
Пример #15
0
u_result
u_serviceDeinit(
    u_service service)
{
    u_result r;
    watchSplicedAdmin admin;
    if (service != NULL) {

        u_dispatcherRemoveListener(u_dispatcher(service),
                                   u_serviceSpliceListener);
        admin = watchSplicedAdmin(service->privateData);
        if (admin) {
            admin->callback = NULL;
            admin->usrData = NULL;
            if (admin->serviceManager != NULL) {
                u_serviceManagerFree(admin->serviceManager);
            }
            os_free(admin);
        }
        service->privateData = NULL;
        r = u_participantDeinit(u_participant(service));
    } else {
        OS_REPORT(OS_ERROR,"u_serviceDeinit",0,
                  "Illegal parameter.");
        r = U_RESULT_ILL_PARAM;
    }
    return r;
}
Пример #16
0
void
v_publicDispose(
    v_public o)
{
    assert(C_TYPECHECK(o,v_public));

    if (o == NULL) {
        return;
    }
    switch(v_objectKind(o)) {
    case K_PARTICIPANT:    v_participantDeinit(v_participant(o));       break;
    case K_PUBLISHER:      v_publisherDeinit(v_publisher(o));           break;
    case K_SUBSCRIBER:     v_subscriberDeinit(v_subscriber(o));         break;
    case K_WRITER:         v_writerDeinit(v_writer(o));                 break;
    case K_DATAREADER:     v_dataReaderDeinit(v_dataReader(o));         break;
    case K_DELIVERYSERVICE:v_deliveryServiceDeinit(v_deliveryService(o)); break;
    case K_NETWORKREADER:  v_networkReaderDeinit(v_networkReader(o));   break;
    case K_READER:         v_readerDeinit(v_reader(o));                 break;
    case K_GROUPQUEUE:     v_groupQueueDeinit(v_groupQueue(o));         break;
    case K_TOPIC:          v_topicDeinit(v_topic(o));                   break;
    case K_ENTITY:                                                      break;
    case K_DOMAIN:         v_partitionDeinit(v_partition(o));           break;
    case K_GROUP:          v_groupDeinit(v_group(o));                   break;
    case K_SERVICEMANAGER: /* Is never freed! */                        break;
    case K_SPLICED:        v_splicedDeinit(v_spliced(o));               break;
    case K_NETWORKING:
    case K_DURABILITY:
    case K_CMSOAP:
    case K_SERVICE:        v_serviceDeinit(v_service(o));               break;
    case K_SERVICESTATE:   /* Is never freed! */                        break;
    case K_CONFIGURATION:                                               break;
    case K_QUERY:
        OS_REPORT(OS_ERROR, "v_publicDispose failure", 
                  0, "deinit of abstract class K_QUERY");
    break;
    case K_DATAREADERQUERY: 
        v_dataReaderQueryDeinit(v_dataReaderQuery(o));
    break;
    case K_DATAVIEWQUERY: 
        v_dataViewQueryDeinit(v_dataViewQuery(o));
    break;
    case K_DATAVIEW:       v_dataViewDeinit(v_dataView(o));             break;
    case K_WAITSET:        v_waitsetDeinit(v_waitset(o));               break;
    case K_WRITERINSTANCE:
        v_writerInstanceDeinit(v_writerInstance(o));
    break;
    case K_DATAREADERINSTANCE:
        v_dataReaderInstanceDeinit(v_dataReaderInstance(o));
    break;
    case K_DATAVIEWINSTANCE:
        v_dataViewInstanceDeinit(v_dataViewInstance(o));
    break;
    default:
        OS_REPORT_1(OS_ERROR,"v_publicDispose failed",0,
                    "illegal entity kind (%d) specified",v_objectKind(o));
        assert(FALSE);
    break;
    }
    c_free(o);
}
Пример #17
0
static void
issueLowMemoryWarning(
    c_voidp arg)
{
#ifdef DDS_1958_CANNOT_CALL_REGISTERED_FUNC_PTR_FROM_DIFF_PROCESS
    os_uint32 warningCount;
    v_handleServer server;

    server = v_handleServer(arg);
    /* dds1958: ES: Check if the warning count is 0 at the moment. If so it
     * means that no warning has been issued. If the value is not 0 however
     * then we do not need to continue and do not need to do any increment
     * and safe out on that code in situations where we get the low memory
     * warning a lot. The idea is that just doing this check (although not
     * a definate yes or no to doing the warning) is in the cases where
     * a warning has already been issued much cheaper then doing the
     * increment and then checking. Only in the situation where the warning
     * is issued for the first time, is this check useless. But that is only
     * 1 time vs many times.
     */
    if(server->lowMemWarningCount == 0)
    {
        /*  increment the warning count
         */
        warningCount = pa_increment(&server->lowMemWarningCount);
        if(warningCount == 1)
        {
            OS_REPORT(OS_WARNING,
                "issueLowMemoryWarning",0,
                "Shared memory is running very low!");

        }
    }
#endif
}
Пример #18
0
static DDS_ReturnCode_t
DDS_QosProviderReadLock (
    gapi_handle handle,
    _QosProvider *object)
{
    _QosProvider qosProvider;
    gapi_returnCode_t gapiResult;
    DDS_ReturnCode_t result = DDS_RETCODE_OK;

    assert (handle != NULL);
    assert (object != NULL);

    qosProvider = (_QosProvider)
        gapi_objectReadClaim (handle, OBJECT_KIND_QOSPROVIDER, &gapiResult);
    result = gapiReturnCodeToReturnCode (gapiResult);

    if (result != DDS_RETCODE_OK) {
        OS_REPORT (OS_ERROR, "DDS_QosProviderReadLock", 0,
            "Could not read lock QosProvider");
    } else {
        *object = qosProvider;
    }

    return result;
}
Пример #19
0
d_sample
d_groupInfoSampleNew (
    d_groupInfo _this,
    d_instance instance,
    v_message msg)
{
    d_sample sample;
    v_message mmfMessage;

    sample = d_sample(c_new(_this->topic->sampleType));

    if (sample) {
        c_cloneIn(_this->topic->messageType, msg, (c_voidp*)&(mmfMessage));
        d_sampleTemplate(sample)->message = mmfMessage;
        sample->instance = instance;
        sample->older = NULL;
        sample->newer = NULL;
    } else {
        OS_REPORT(OS_ERROR,
              "d_groupInfoSampleNew",0,
              "Failed to allocate sample.");
        assert(FALSE);
    }
    return sample;
}
Пример #20
0
DDS::Subscriber_impl::~Subscriber_impl()
{
  if (os_mutexDestroy(&s_mutex) != os_resultSuccess)
  {
    OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to destroy mutex");
  }
}
Пример #21
0
v_cache
v_groupCacheNew (
    v_kernel kernel,
    v_cacheKind kind)
{
    c_base base;
    c_type type;
    v_cache cache;

    assert(C_TYPECHECK(kernel,v_kernel));

    base = c_getBase(kernel);
    type = c_keep(v_kernelType(kernel,K_GROUPCACHEITEM));
    cache = v_cacheNew(kernel,type,kind);
    c_free(type);

    if (!cache) {
        OS_REPORT(OS_ERROR,
                  "v_groupCacheNew",0,
                  "Failed to allocate group cache.");
    }

    assert(C_TYPECHECK(cache, v_cache));

    return cache;
}
Пример #22
0
u_result
u_readerGetDeadlineMissedStatus(
    u_reader _this,
    c_bool reset,
    v_statusAction action,
    c_voidp arg)
{
    v_reader reader;
    u_result result;

    result = U_RESULT_PRECONDITION_NOT_MET;
    if (_this != NULL) {
        result = u_entityReadClaim(u_entity(_this), (v_entity*)(&reader));
        if (result == U_RESULT_OK){
            result = u_resultFromKernel(
                         v_readerGetDeadlineMissedStatus(reader,
                                                         reset,
                                                         (v_statusAction)action,
                                                         arg));
            u_entityRelease(u_entity(_this));
        }  else {
            OS_REPORT(OS_ERROR, "u_readerDeadlineMissedStatus", 0,
                      "Illegal handle detected");
        }
    }
    return result;
}
Пример #23
0
u_result
u_serviceRenewLease(
    u_service _this,
    v_duration leasePeriod)
{
    u_result r;
    v_service kernelService;

    if (_this == NULL) {
        r = U_RESULT_ILL_PARAM;
    } else {
        r = u_entityReadClaim(u_entity(_this), (v_entity*)(&kernelService));
        if(r == U_RESULT_OK)
        {
            assert(kernelService);
            v_serviceRenewLease(kernelService, leasePeriod);
            r = u_entityRelease(u_entity(_this));
        } else {
            OS_REPORT(OS_WARNING,
                      "u_serviceRenewLease", 0,
                      "Failed to claim service.");
        }
    }
    return r;
}
Пример #24
0
v_groupCacheItem
v_groupCacheItemNew (
    v_groupInstance groupInstance,
    v_instance instance)
{
    v_groupCacheItem item;
    v_cache cache;

    assert(groupInstance != NULL);
    assert(instance != NULL);
    assert(C_TYPECHECK(groupInstance,v_groupInstance));
    assert(C_TYPECHECK(instance,v_instance));

    cache = groupInstance->targetCache;
    item = v_groupCacheItem(v_cacheNodeNew(cache));
    if (item) {
    	v_cacheItem(item)->instance = instance;
    	item->groupInstance = groupInstance;
    	item->registrationCount = 1;
        item->pendingResends = 0;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_groupCacheItemNew",0,
                  "Failed to allocate group cache item.");
    }

    assert(C_TYPECHECK(item,v_groupCacheItem));

    return item;
}
Пример #25
0
v_dataViewInstance
v_dataViewInstanceNew(
    v_dataView dataView,
    v_dataViewSample viewSample)
{
    v_dataViewInstance instance;

    assert(dataView);
    assert(viewSample);
    assert(C_TYPECHECK(dataView,v_dataView));
    assert(C_TYPECHECK(viewSample,v_dataViewSample));

    instance = v_dataViewInstance(c_new(dataView->instanceType));
    if (instance) {
        v_object(instance)->kernel = v_objectKernel(dataView);
        v_objectKind(instance) = K_DATAVIEWINSTANCE;
        v_instanceInit(v_instance(instance), v_entity(dataView));
        viewSample->next = viewSample;
        v_dataViewInstanceTemplate(instance)->sample = viewSample;
        instance->sampleCount = 1;

        v_stateSet(v_instanceState(instance),L_NEW);
        v_stateClear(v_readerSample(viewSample)->sampleState,L_READ);

        assert(C_TYPECHECK(instance,v_dataViewInstance));
        CHECK_INSTANCE(instance);
    } else {
        OS_REPORT(OS_FATAL, OS_FUNCTION, V_RESULT_INTERNAL_ERROR,
            "Failed to allocate v_dataViewInstance");
        assert(FALSE);
    }

    return instance;
}
DDS::ContentFilteredTopic_impl::~ContentFilteredTopic_impl()
{
    if (os_mutexDestroy(&cft_mutex) != os_resultSuccess)
    {
        OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to destroy mutex");
    }
}
DDS::DomainParticipant_impl::~DomainParticipant_impl()
{
  if (os_mutexDestroy(&dp_mutex) != os_resultSuccess)
  {
    OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to destroy mutex");
  }
}
DDS::StatusCondition_impl::~StatusCondition_impl( )
{
  if (os_mutexDestroy(&sc_mutex) != os_resultSuccess)
  {
    OS_REPORT(OS_ERROR, "CCPP", 0, "Unable to destroy mutex");
  }
}
Пример #29
0
void
cmx_writerDataTypeAction(
    v_entity entity,
    c_voidp args)
{
    sd_serializer ser;
    sd_serializedData data;
    c_type type;
    struct cmx_writerTypeArg *arg;
    arg = (struct cmx_writerTypeArg *)args;
    
    type = NULL;
    
    switch(v_object(entity)->kind){
    case K_WRITER:
        type = v_topicDataType(v_writer(entity)->topic);      
    break;
    default:
        OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Trying to resolve dataType of writer that is not a writer.\n");
        assert(FALSE);
    break;
    }
    
    if(type != NULL){
        ser = sd_serializerXMLMetadataNew(c_getBase(type));
        data = sd_serializerSerialize(ser, type);
        arg->result = sd_serializerToString(ser, data);
        sd_serializedDataFree(data);
        sd_serializerFree(ser);
    }
}
Пример #30
0
v_service
v_serviceNew(
    v_kernel kernel,
    const c_char *name,
    const c_char *extStateName,
    v_serviceType serviceType,
    v_participantQos qos,
    c_bool enable)
{
    v_service s = NULL;
    v_participantQos q;

    assert(C_TYPECHECK(kernel, v_kernel));
    /* Do not C_TYPECHECK qos parameter, since it might be allocated on heap! */
    assert(name != NULL);

    if (v_participantQosCheck(qos) == V_RESULT_OK) {
        q = v_participantQosNew(kernel, (v_participantQos)qos);
        if (q == NULL) {
            OS_REPORT(OS_ERROR, "v_serviceNew", V_RESULT_INTERNAL_ERROR,
                "Creation of service <%s> failed. Cannot create participant QoS.",
                name);
        } else {
            s = v_service(v_objectNew(kernel, K_SERVICE));
            v_serviceInit(s, name, extStateName, serviceType, q, enable);
            c_free(q);
            if (s->state == NULL) {
                v_serviceFree(s);
                s = NULL;
            }
        }
    }

    return s;
}