Esempio n. 1
0
c_bool
v_querySetParams(
    v_query q,
    q_expr predicate,
    c_value params[])
{
    c_bool result = FALSE;

    assert(C_TYPECHECK(q,v_query));

    if (q != NULL) {
        switch (v_objectKind(q)) {
        case K_DATAREADERQUERY:
            result = v_dataReaderQuerySetParams(v_dataReaderQuery(q),
                                                predicate,
                                                params);
        break;
        case K_DATAVIEWQUERY:
            result = v_dataViewQuerySetParams(v_dataViewQuery(q),
                                              predicate,
                                              params);
        break;
        default:
            OS_REPORT_1(OS_ERROR,
                        "v_querySetParams failed",0,
                        "illegal query kind (%d) specified",
                        v_objectKind(q));
            assert(FALSE);
        }
    }

    return result;
}
Esempio n. 2
0
v_partition
v_addPartition(
    v_kernel kernel,
    v_partition partition)
{
    v_partition found;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));
    assert(partition != NULL);
    assert(C_TYPECHECK(partition,v_partition));

    c_lockWrite(&kernel->lock);
    found = c_insert(kernel->partitions,partition);
    c_lockUnlock(&kernel->lock);

    if (found != partition) {
        assert(v_objectKind(found) == K_DOMAIN);
        if (v_objectKind(found) != K_DOMAIN) {
            partition = NULL;
        } else {
            partition = found;
        }
    }
    return partition;
}
Esempio n. 3
0
c_bool
v_readerUnSubscribe(
    v_reader r,
    v_partition d)
{
    assert(C_TYPECHECK(r,v_reader));

    switch(v_objectKind(r)) {
    case K_DATAREADER:
        return v_dataReaderUnSubscribe(v_dataReader(r),d);
    case K_DELIVERYSERVICE:
        return v_deliveryServiceUnSubscribe(v_deliveryService(r),d);
    case K_GROUPQUEUE:
        return v_groupStreamUnSubscribe(v_groupStream(r),d);
    case K_NETWORKREADER:
        return v_networkReaderUnSubscribe(v_networkReader(r),d);
    default:
        OS_REPORT_1(OS_ERROR,"v_readerUnSubscribe failed",0,
                    "illegal reader kind (%d) specified",
                    v_objectKind(r));
        assert(FALSE);
    }

    return TRUE;
}
Esempio n. 4
0
/**************************************************************
 * Public functions
 **************************************************************/
c_bool
v_readerSubscribe(
    v_reader r,
    v_partition d)
{
    c_bool result;

    assert(C_TYPECHECK(r,v_reader));

    switch(v_objectKind(r)) {
    case K_DATAREADER:
        result = v_dataReaderSubscribe(v_dataReader(r),d);
    break;
    case K_DELIVERYSERVICE:
        result = v_deliveryServiceSubscribe(v_deliveryService(r),d);
    break;
    case K_GROUPQUEUE:
        result = v_groupStreamSubscribe(v_groupStream(r),d);
    break;
    case K_NETWORKREADER:
        result = v_networkReaderSubscribe(v_networkReader(r),d);
    break;
    default:
        OS_REPORT_1(OS_ERROR,"v_readerSubscribe failed",0,
                    "illegal reader kind (%d) specified",
                    v_objectKind(r));
        assert(FALSE);
        result = FALSE;
    break;
    }
    readerGetHistoricalData(r);

    return result;
}
Esempio n. 5
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);
}
Esempio n. 6
0
v_writeResult
v_entryResend(
    v_entry e,
    v_message o)
{
    v_writeResult writeResult;

    assert(C_TYPECHECK(e,v_entry));
    assert(C_TYPECHECK(o,v_message));

    switch(v_objectKind(e->reader)) {
    case K_NETWORKREADER:
        writeResult = V_WRITE_SUCCESS;
    break;
    case K_DATAREADER:
    default:
        OS_REPORT_1(OS_ERROR,
                    "v_entryWrite failed",0,
                    "illegal reader kind (%d) specified",
                    v_objectKind(e->reader));
        assert(FALSE);
        return V_WRITE_UNDEFINED;
    }

    return writeResult;
}
Esempio n. 7
0
c_bool
v_queryTriggerTest(
    v_query q)
{
    c_bool result = FALSE;

    if (q == NULL) {
        return FALSE;
    }

    assert(C_TYPECHECK(q,v_query));

    switch (v_objectKind(q)) {
    case K_DATAREADERQUERY:
        result = v_dataReaderQueryTriggerTest(v_dataReaderQuery(q));
    break;
    case K_DATAVIEWQUERY:
        result = v_dataViewQueryTest(v_dataViewQuery(q));
    break;
    default:
        OS_REPORT_1(OS_ERROR,
                    "v_queryTest failed",0,
                    "illegal query kind (%d) specified",
                    v_objectKind(q));
        assert(FALSE);
    }

    return result;
}
Esempio n. 8
0
c_bool
v_queryNotifyDataAvailable(
    v_query _this,
    v_event event)
{
    c_bool result = TRUE;

    switch (v_objectKind(_this)) {
    case K_DATAREADERQUERY:
        result = v_dataReaderQueryNotifyDataAvailable(
                     v_dataReaderQuery(_this),
                     event);
    break;
    case K_DATAVIEWQUERY:
        result = v_dataViewQueryNotifyDataAvailable(
                     v_dataViewQuery(_this),
                     event);
    break;
    default:
    break;
        OS_REPORT_1(OS_ERROR,
                    "v_queryNotifyDataAvailable failed",0,
                    "illegal query kind (%d) specified",
                    v_objectKind(_this));
        assert(FALSE);
        result = TRUE;
    }
    return result;
}
Esempio n. 9
0
c_bool
v_readerUnSubscribeGroup(
    v_reader reader,
    v_group group)
{
    c_bool result;

    assert(C_TYPECHECK(reader, v_reader));

    switch(v_objectKind(reader)) {
    case K_DATAREADER:
        result = v_dataReaderUnSubscribeGroup(v_dataReader(reader), group);
    break;
    case K_GROUPQUEUE:
        result = v_groupStreamUnSubscribeGroup(v_groupStream(reader), group);
    break;
    case K_NETWORKREADER:
        result = v_networkReaderUnSubscribeGroup(v_networkReader(reader), group);
    break;
    default:
        OS_REPORT_1(OS_ERROR,"v_readerUnSubscribeGroup failed",0,
                    "illegal reader kind (%d) specified",
                    v_objectKind(reader));
        assert(FALSE);
        result = FALSE;
    }

    return result;
}
Esempio n. 10
0
v_writeResult
v_groupStreamWrite(
    v_groupStream stream,
    v_groupAction action)
{
    v_writeResult result;

    assert(C_TYPECHECK(stream,v_groupStream));
    assert(C_TYPECHECK(action, v_groupAction));

    result = V_WRITE_ERROR;

    switch(v_objectKind(stream)){
        case K_GROUPQUEUE:
            result = v_groupQueueWrite(v_groupQueue(stream), action);
            break;
        default:
            OS_REPORT_1(OS_ERROR,"v_groupStreamWrite",0,
                        "illegal entity kind (%d) specified",
                        v_objectKind(stream));
            assert(FALSE);
            break;
    }
    return result;
}
Esempio n. 11
0
void
v_subscriberFree(
    v_subscriber s)
{
    v_kernel kernel;
    v_participant p;
    v_reader o;
    v_entity found;
    c_long sc;

    kernel = v_objectKernel(s);

    sc = (c_long)pa_decrement(&(s->shareCount));
    if (sc > 0) return;

    if(sc == 0){
        v_observableRemoveObserver(v_observable(kernel->groupSet),v_observer(s), NULL);
        if (s->qos->share.enable) {
            found = v_removeShare(kernel,v_entity(s));
            assert(found == v_entity(s));
            c_free(found);
        }
        while ((o = c_take(s->readers)) != NULL) {
            switch (v_objectKind(o)) {
            case K_DATAREADER:
                v_dataReaderFree(v_dataReader(o));
            break;
            case K_DELIVERYSERVICE:
                v_deliveryServiceFree(v_deliveryService(o));
            break;
            case K_GROUPQUEUE:
                v_groupQueueFree(v_groupQueue(o));
            break;
            case K_NETWORKREADER:
                v_networkReaderFree(v_networkReader(o));
            break;
            default:
                OS_REPORT_1(OS_ERROR,
                            "v_subscriber", 0,
                            "Unknown reader %d",
                            v_objectKind(o));
                assert(FALSE);
            break;
            }
            c_free(o);
        }
        p = v_participant(s->participant);
        if (p != NULL) {
            v_participantRemove(p,v_entity(s));
            s->participant = NULL;
        }
        v_publicFree(v_public(s));
    } else {
        OS_REPORT_1(OS_ERROR,  "v_subscriberFree", 0,
                "subscriber already freed (shareCount is now %d).", sc);
        assert(sc == 0);
    }
}
Esempio n. 12
0
c_iter
v_deadLineInstanceListCheckDeadlineMissed(
    v_deadLineInstanceList list,
    v_duration deadlineTime,
    c_time now)
{
    c_time expiryTime;
    v_instance listItem;
    c_iter missed;

    assert(C_TYPECHECK(list,v_deadLineInstanceList));

    missed = NULL;
    if (v_instanceAlone(v_instance(list))) { /* list is empty */
        assert (list->deadlineLease != NULL);
        v_leaseManagerDeregister(list->leaseManager, list->deadlineLease);
        c_free(list->deadlineLease);
        list->deadlineLease = NULL;
    } else {
        listItem = v_instance(list)->prev;
        expiryTime = c_timeSub(now, deadlineTime);
        while ((listItem != NULL) &&
                (v_objectKind(listItem) != K_DEADLINEINSTANCE)  &&
                (c_timeCompare(expiryTime, listItem->lastCheckTime) != C_LT)) {
            missed = c_iterInsert(missed, listItem);
            listItem->lastCheckTime = now;
            listItem = listItem->prev;
        }
        /* determine next wake-up time */
        if (v_objectKind(listItem) == K_DEADLINEINSTANCE) {
            /* listItem is the deadline list itself, so if there
             * were instances all instances have been missed. Just
             * set the new check to be in 'deadlineTime'.
             */
            expiryTime = deadlineTime;
        } else {
            /*
             * The new lease duration can be calculated:
             * lastCheckTime + deadlineTime = next expiry time
             * next expiry time - now = lease duration
             */
            expiryTime = c_timeAdd(listItem->lastCheckTime, deadlineTime);
            expiryTime = c_timeSub(expiryTime, now);
            v_leaseRenew(list->deadlineLease, expiryTime);
        }
    }
    return missed;
}
Esempio n. 13
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;
}
Esempio n. 14
0
v_deadLineInstanceList
v_deadLineInstanceListNew(
    c_base base,
    v_leaseManager leaseManager,
    v_duration leaseDuration,
    v_leaseActionId actionId,
    v_public o)
{
    v_deadLineInstanceList list;
    c_type type;

    assert(C_TYPECHECK(leaseManager,v_leaseManager));
    assert(C_TYPECHECK(o,v_public));

    type = c_resolve(base, "kernelModule::v_deadLineInstanceList");
    assert(type);
    list = c_new(type);
    c_free(type);
    if (list) {
        v_objectKind(list) = K_DEADLINEINSTANCE;
        v_instanceInit(v_instance(list));
        list->leaseManager = c_keep(leaseManager);
        list->leaseDuration = leaseDuration;
        list->deadlineLease = NULL;
        list->actionObject = o; /* no keep, since actionObject is onwer of v_deadLineInstanceList */
        list->actionId = actionId;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_deadLineInstanceListNew",0,
                  "Failed to allocate v_deadLineInstanceList.");
    }

    return list;
}
Esempio n. 15
0
void
v_instanceUnregister (
    v_instance instance,
    v_registration registration,
    c_time timestamp)
{
    c_char* metaName;

    assert(C_TYPECHECK(instance, v_instance));

    switch (v_objectKind(instance)) {
    case K_DATAREADERINSTANCE:
        v_dataReaderInstanceUnregister(v_dataReaderInstance(instance),
                registration, timestamp);
    break;
    default:
        metaName = c_metaName(c_metaObject(c_getType(instance)));
        OS_REPORT_1(OS_ERROR,
                    "v_instanceUnregister",0,
                    "Unknown instance type <%s>",
                    metaName);
        c_free(metaName);
    break;
    }
}
Esempio n. 16
0
static c_bool
notifyGroupQueues(
    v_reader reader,
    v_group group)
{
    if(v_objectKind(reader) == K_GROUPQUEUE){
        v_groupStreamConnectNewGroups(v_groupStream(reader), group);
    }
    return TRUE;
}
Esempio n. 17
0
v_collection
v_querySource(
    v_query q)
{
    v_collection c;

    if (q == NULL) {
        return NULL;
    }

    assert(C_TYPECHECK(q,v_query));

    c = v_collection(q->source);
    if (c == NULL) {
        OS_REPORT_1(OS_ERROR,
                    "v_querySource failed",0,
                    "Query (0x%x) without source detected",
                    q);
        assert(FALSE);
        return NULL;
    }

    switch(v_objectKind(c)) {
    case K_DATAREADER:
    case K_DATAVIEW:
        c_keep(c);
    break;
    case K_DATAREADERQUERY:
    case K_DATAVIEWQUERY:
        c = v_querySource(v_query(c));
    break;
    default:
        OS_REPORT_1(OS_ERROR,
                    "v_querySource failed",0,
                    "illegal source kind (%d) detected",
                    v_objectKind(c));
        assert(FALSE);
        return NULL;
    }
    return c;
}
Esempio n. 18
0
static c_bool
assertLivelinessPublisher(
    c_object o,
    c_voidp arg)
{
    v_entity e = v_entity(o);

    if (v_objectKind(e) == K_PUBLISHER) {
        v_publisherAssertLiveliness(v_publisher(e), (v_event)arg);
    }
    return TRUE;
}
Esempio n. 19
0
/**************************************************************
 * Protected functions
 **************************************************************/
c_bool
v_readerSubscribeGroup(
    v_reader _this,
    v_group group)
{
    c_bool result;

    assert(C_TYPECHECK(_this, v_reader));
    switch(v_objectKind(_this)) {
    case K_DATAREADER:
        /* ES, dds1576: For the K_DATAREADER object we need to verify if
         * the access rights are correct. No subscriptions may be made onto
         * groups which have a v_accessMode of write only.
         */
        if(v_groupPartitionAccessMode(group) == V_ACCESS_MODE_READ_WRITE ||
           v_groupPartitionAccessMode(group) == V_ACCESS_MODE_READ)
        {
            result = v_dataReaderSubscribeGroup(v_dataReader(_this), group);
            readerGetHistoricalData(_this);
        } else
        {
            result = FALSE;
        }
    break;
    case K_GROUPQUEUE:
        result = v_groupStreamSubscribeGroup(v_groupStream(_this), group);
    break;
    case K_NETWORKREADER:
        result = v_networkReaderSubscribeGroup(v_networkReader(_this), group);
        readerGetHistoricalData(_this);
    break;
    default:
        OS_REPORT_1(OS_ERROR,"v_readerSubscribeGroup failed",0,
                    "illegal reader kind (%d) specified",
                    v_objectKind(_this));
        assert(FALSE);
        result = FALSE;
    }
    return result;
}
Esempio n. 20
0
v_query
v_queryNew (
    v_collection source,
    const c_char *name,
    q_expr predicate,
    c_value params[])
{
    v_query q;
    v_dataReader reader;
    v_dataView readerView;

    assert(C_TYPECHECK(source,v_collection));

    q = NULL;

    switch(v_objectKind(source)) {
    case K_DATAREADER:
        reader = v_dataReader(source);
        q = v_query(v_dataReaderQueryNew(
                        reader,
                        name,
                        predicate,
                        params));
    break;
    case K_DATAVIEW:
        readerView = v_dataView(source);
        q = v_query(v_dataViewQueryNew(
                        readerView,
                        name,
                        predicate,
                        params));
    break;
    default:
        OS_REPORT_1(OS_ERROR,
                    "v_queryNew failed",0,
                    "illegal source kind (%d) specified",
                    v_objectKind(source));
    }
    return q;
}
Esempio n. 21
0
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;
}
Esempio n. 22
0
/* ----------------------------------- Private ------------------------------ */
static c_bool
qosChangedAction(
    c_object o,
    c_voidp arg)
{
    v_dataReader r;

    if (v_objectKind(o) == K_DATAREADER) {
        r = v_dataReader(o);
        v_dataReaderUpdateConnections(r,(v_dataReaderConnectionChanges *)arg);
        v_dataReaderNotifyChangedQos(r);
    }

    return TRUE;
}
Esempio n. 23
0
void
livelinessCheck(
    v_leaseManager _this,
    v_leaseAction leaseAction)
{
    v_object o;
    v_handleResult r;

    assert(leaseAction != NULL);
    assert(C_TYPECHECK(leaseAction, v_leaseAction));

    /* Liveliness lease expired, so the reader/writer must be notified! */
    r = v_handleClaim(leaseAction->actionObject, &o);
    if (r == V_HANDLE_OK)
    {
        v_writerNotifyLivelinessLost(v_writer(o));
        if (v_objectKind(o) != K_WRITER)
        {
            OS_REPORT_1(OS_WARNING, "v_lease", 0,
                        "entity %d has no liveliness policy",
                        v_objectKind(o));
        }
        r = v_handleRelease(leaseAction->actionObject);
        if(r != V_HANDLE_OK)
        {
            OS_REPORT_1(OS_WARNING, "v_leaseManager", 0,
                "Handle release failed with result code %d ", r);
        }
    } else
    {
        /* Corresponding reader/writer is already gone, so remove this lease
         * from its leasemanager.
         */
        v_leaseManagerDeregister(_this, leaseAction->lease);
    }
}
Esempio n. 24
0
u_instanceHandle
u_instanceHandleFix(
    u_instanceHandle _this,
    v_collection reader)
{
    u_instanceHandleTranslator translator;
    struct v_publicationInfo *data;
    v_topic topic;
    v_message message;
    v_public instance;

    translator.handle = _this;
    if (translator.lid.lifecycleId & HANDLE_GLOBAL_MASK) {
        /* Is a GID therefore fix handle by lookup. */
        while (v_objectKind(v_entity(reader)) == K_QUERY ||
               v_objectKind(v_entity(reader)) == K_DATAREADERQUERY ||
               v_objectKind(v_entity(reader)) == K_DATAVIEWQUERY) {
            /* If the entity derives from a query entity it can be cast to a v_query */
            reader = v_querySource(v_query(reader));
        }
        while (v_objectKind(v_entity(reader)) == K_DATAVIEW) {
            reader = v_collection(v_dataViewGetReader(v_dataView(reader)));
        }
        topic = v_dataReaderGetTopic(v_dataReader(reader));
        message = v_topicMessageNew(topic);
        data = (c_voidp)C_DISPLACE(message, v_topicDataOffset(topic));
        data->key = u_instanceHandleToGID(_this);
        instance = (v_public)v_dataReaderLookupInstance(v_dataReader(reader),
                                                        message);
        translator.handle = u_instanceHandleNew(instance);
        c_free(instance);
        c_free(topic);
        c_free(message);
    }
    return translator.handle;
}
Esempio n. 25
0
v_writeResult
v_entryWrite(
    v_entry e,
    v_message o,
    v_networkId writingNetworkId,
    v_instance *instance)
{
    v_writeResult writeResult;

    assert(C_TYPECHECK(e,v_entry));
    assert(C_TYPECHECK(o,v_message));

    switch(v_objectKind(e->reader)) {
    case K_DATAREADER:
        writeResult = v_dataReaderEntryWrite(v_dataReaderEntry(e),
                                             o,
                                             instance,
                                             C_TIME_MIN_INFINITE);
    break;
    case K_NETWORKREADER:
        writeResult = v_networkReaderEntryWrite(v_networkReaderEntry(e),
                                                o, writingNetworkId);
    break;
    case K_DELIVERYSERVICE:
        writeResult = v_deliveryServiceEntryWrite(v_deliveryServiceEntry(e),o,instance);
    break;
    default:
        OS_REPORT_1(OS_ERROR,
                    "v_entryWrite failed",0,
                    "illegal reader kind (%d) specified",
                    v_objectKind(e->reader));
        assert(FALSE);
        return V_WRITE_UNDEFINED;
    }
    return writeResult;
}
Esempio n. 26
0
static void
getStatusMask(
    v_entity e,
    c_voidp arg)
{
    c_long *mask = (c_long *)arg;

    if ( v_objectKind(e) == K_SUBSCRIBER ) {
        if ( !c_setWalk(v_subscriber(e)->readers, (c_action)readerHasDataAvailable, NULL) ) {
            *mask = V_EVENT_DATA_AVAILABLE;
        } else {
            *mask = 0;
        }
    } else {
        *mask = v_statusGetMask(e->status);
    }
}
Esempio n. 27
0
static c_bool
connectNewGroup(
    c_object o,
    c_voidp arg)
{
    switch (v_objectKind(o)) {
    case K_PUBLISHER:
        v_publisherConnectNewGroup(v_publisher(o), (v_group)arg);
    break;
    case K_SUBSCRIBER:
        v_subscriberConnectNewGroup(v_subscriber(o), (v_group)arg);
    break;
    default:
        /* Other entities do not connect */
    break;
    }
    return TRUE;
}
Esempio n. 28
0
void
v_deadLineInstanceListSetDuration(
    v_deadLineInstanceList list,
    v_duration duration)
{
    v_kernel k;
    v_result result;

    assert(C_TYPECHECK(list,v_deadLineInstanceList));

    list->leaseDuration = duration;
    if (list->deadlineLease != NULL) {
        if (c_timeCompare(duration, C_TIME_INFINITE) != C_EQ) {
            v_leaseRenew(list->deadlineLease,duration);
        } else {
            v_leaseManagerDeregister(list->leaseManager, list->deadlineLease);
            c_free(list->deadlineLease);
            list->deadlineLease = NULL;
        }
    } else {
        if ((v_objectKind(v_instance(list)->prev) != K_DEADLINEINSTANCE) &&  /* not in list */
                (c_timeCompare(duration, C_TIME_INFINITE) != C_EQ)) { /* new instance */
            k = v_objectKernel(list->leaseManager);
            list->deadlineLease = v_leaseNew(k, duration);
            if(list->deadlineLease)
            {
                result = v_leaseManagerRegister(
                             list->leaseManager,
                             list->deadlineLease,
                             list->actionId,
                             v_public(list->actionObject),
                             TRUE /* repeat lease if expired */);
                if(result != V_RESULT_OK)
                {
                    c_free(list->deadlineLease);
                    list->deadlineLease = NULL;
                    OS_REPORT_1(OS_ERROR, "v_deadLineInstanceList", 0,
                                "A fatal error was detected when trying to register the deadline lease."
                                "The result code was %d.", result);
                }
            }
        }
    }
}
Esempio n. 29
0
v_dataViewInstance
v_dataViewInstanceNew(
    v_dataView dataView,
    v_readerSample sample)
{
    v_dataViewInstance instance;
    v_dataViewSample viewSample;

    assert(dataView);
    assert(sample);
    assert(C_TYPECHECK(dataView,v_dataView));
    assert(C_TYPECHECK(sample,v_readerSample));

    instance = v_dataViewInstance(c_new(dataView->instanceType));
    if (instance) {
        v_object(instance)->kernel = v_objectKernel(dataView);
        v_objectKind(instance) = K_DATAVIEWINSTANCE;
        instance->dataView = (c_voidp)dataView;

        viewSample = v_dataViewSampleNew(instance,sample);
        if (viewSample) {
            v_dataViewInstanceTemplate(instance)->sample = viewSample;
            viewSample->next = NULL;
            viewSample->prev = NULL;
            v_readerSampleAddViewSample(sample,viewSample);
            instance->sampleCount = 1;

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

            assert(C_TYPECHECK(instance,v_dataViewInstance));
            v_dataViewNotifyDataAvailable(dataView, viewSample);
        }
        CHECK_INSTANCE(instance);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_dataViewInstanceNew",0,
                  "Failed to allocate v_dataViewInstancem");
        assert(FALSE);
    }

    return instance;
}
Esempio n. 30
0
static void
jni_writerTypeAction(
    v_entity entity, 
    c_voidp args)
{
    struct jni_writerTypeArg *arg;
    arg = (struct jni_writerTypeArg *)args;
    
    arg->type = NULL;
    
    switch(v_objectKind(entity)){
    case K_TOPIC:
        arg->type = v_topicDataType(entity);      
    break;
    default:
        OS_REPORT(OS_ERROR, "dcpsjni", 0, "Trying to resolve dataType of writer that is not a writer.\n");
        assert(FALSE);
    break;
    }
}