void cmx_participantDomainsAction( v_public p, c_voidp args) { cmx_walkEntityArg arg; c_iter partitions; v_entity partition; c_bool proceed; c_char* xmlEntity; arg = cmx_walkEntityArg(args); partitions = v_resolvePartitions(v_objectKernel(p), "*"); partition = v_entity(c_iterTakeFirst(partitions)); while(partition != NULL){ proceed = cmx_entityNewFromWalk(v_public(partition), &arg->entityArg); if(proceed == TRUE){ xmlEntity = arg->entityArg.result; arg->list = c_iterInsert(arg->list, xmlEntity); arg->length += strlen(xmlEntity); } c_free(partition); partition = v_entity(c_iterTakeFirst(partitions)); } c_iterFree(partitions); }
void v_topicAdapterNotify( v_topicAdapter adapter, v_event event, c_voidp userData) { C_STRUCT(v_event) e; c_bool forward = TRUE; OS_UNUSED_ARG(userData); assert(adapter != NULL); assert(C_TYPECHECK(adapter,v_topicAdapter)); assert(event != NULL); switch (event->kind) { case V_EVENT_ALL_DATA_DISPOSED: v_statusNotifyAllDataDisposed(v_entity(adapter)->status); break; case V_EVENT_INCONSISTENT_TOPIC: v_statusNotifyInconsistentTopic(v_entity(adapter)->status); break; default: forward = FALSE; break; } if (forward) { e.kind = event->kind; e.source = v_observable(adapter); e.data = NULL; (void)v_entityNotifyListener(v_entity(adapter), &e); } }
void cmx_participantFindTopicAction( v_public p, c_voidp args) { cmx_walkEntityArg arg; c_iter topics; v_entity topic; c_bool proceed; c_char* xmlEntity; arg = cmx_walkEntityArg(args); topics = v_resolveTopics(v_objectKernel(p), cmx_walkParticipantArg(arg)->topicName); topic = v_entity(c_iterTakeFirst(topics)); while(topic != NULL){ proceed = cmx_entityNewFromWalk(v_public(topic), &arg->entityArg); if(proceed == TRUE){ xmlEntity = arg->entityArg.result; arg->list = c_iterInsert(arg->list, xmlEntity); arg->length += strlen(xmlEntity); } c_free(topic); topic = v_entity(c_iterTakeFirst(topics)); } c_iterFree(topics); }
void v_topicAdapterInit( v_topicAdapter adapter, v_topic topic, v_participant p, const c_char *name) { v_eventMask mask = V_EVENT_ALL_DATA_DISPOSED | V_EVENT_INCONSISTENT_TOPIC; assert(adapter != NULL); assert(p != NULL); assert(C_TYPECHECK(adapter, v_topicAdapter)); assert(C_TYPECHECK(p,v_participant)); assert(C_TYPECHECK(topic,v_topic)); v_entityInit(v_entity(adapter), name); adapter->topic = c_keep(topic); (void)v_entityEnable(v_entity(adapter)); (void)v_observerSetEvent(v_observer(adapter), mask); OSPL_ADD_OBSERVER(topic, adapter, mask, NULL); v_participantAdd(p, v_object(adapter)); v_topic(adapter)->owner = p; }
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); } }
static u_result handleGroup( v_service service, v_group group) { v_networkReaderEntry entry; in_printf(IN_LEVEL_FINE, "Found new group '%s.%s'; adding networkReaderEntry...\n", v_entity(group->partition)->name, v_entity(group->topic)->name); entry = v_networkReaderEntryNew( vclientReader, group, v_publicGid(v_public(service)).systemId, 1, 0); if (group->topic->qos->durability.kind >= V_DURABILITY_TRANSIENT) { /* For transient topics, DDSI readers are spontaneously generated to ensure data will indeed arrive -- FIXME: currently no provision is made to ensure no "early" publications are lost while DDSI discovery is still digesting these readers. For convenience, we use the regular DDS<->DDSI mapping to handle these ficitious readers, and we pretend these ficitious readers are owned by the DDSI service participant. That one has been created, and as luck has it, the participants are discovered before the groups are. So we just look it up. */ v_builtinTopicKey pkey; in_participant p; in_printf(IN_LEVEL_FINE, "Group is transient - creating DDSI data reader...\n"); os_mutexLock (&gluelock); pkey = u_entityGid ((u_entity) participant); if ((p = in_participantLookup (&pkey)) == NULL) in_printf (IN_LEVEL_SEVERE, "handleGroup: participant lookup of self failed, transient data may not work\n"); else { if (!in_fictitiousTransientReaderNew (p, group)) { in_printf (IN_LEVEL_SEVERE, "handleGroup: creation of fictitious transient data reader failed, transient data may not work\n"); } } os_mutexUnlock (&gluelock); } v_networkReaderEntryNotifyConnected(entry, SERVICE_NAME); v_networkReaderRemoteActivityDetected(vclientReader); return U_RESULT_OK; }
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; }
v_result v_topicAdapterGetAllDataDisposedStatus( v_topicAdapter _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(C_TYPECHECK(_this,v_topicAdapter)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { OSPL_LOCK(_this); status = v_entity(_this)->status; result = action(&v_topicStatus(status)->allDataDisposed, arg); if (reset) { v_statusReset(status, V_EVENT_ALL_DATA_DISPOSED); } v_topicStatus(status)->allDataDisposed.totalChanged = 0; OSPL_UNLOCK(_this); } return result; }
v_result v_topicAdapterGetInconsistentTopicStatus( v_topicAdapter _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(C_TYPECHECK(_this,v_topicAdapter)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { OSPL_LOCK(_this); status = v_entity(_this)->status; result = action(&v_topicStatus(status)->inconsistentTopic, arg); if (reset) { v_statusReset(status, V_EVENT_INCONSISTENT_TOPIC); } v_topicStatus(status)->inconsistentTopic.totalChanged = 0; OSPL_UNLOCK(_this); } return result; }
v_result v_readerGetLivelinessChangedStatus( v_reader _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(_this != NULL); assert(C_TYPECHECK(_this,v_reader)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { V_READER_LOCK(_this); status = v_entity(_this)->status; result = action(&v_readerStatus(status)->livelinessChanged, arg); if (reset) { v_statusReset(status, V_EVENT_LIVELINESS_CHANGED); } v_readerStatus(status)->livelinessChanged.activeChanged = 0; v_readerStatus(status)->livelinessChanged.inactiveChanged = 0; V_READER_UNLOCK(_this); } return result; }
v_partition v_partitionNew( v_kernel kernel, const c_char *name, v_partitionQos qos) { v_partition partition, found; assert(kernel != NULL); assert(C_TYPECHECK(kernel,v_kernel)); assert(name != NULL); assert(v_partitionExpressionIsAbsolute(name)); partition = v_partition(v_objectNew(kernel,K_DOMAIN)); v_entityInit(v_entity(partition),name, NULL, TRUE); found = v_addPartition(kernel,partition); if (found != partition) { v_partitionFree(partition); c_free(partition); /* v_partitionFree has removed all dependancies, now delete local reference */ partition = c_keep(found); /* this one will be returned, so a keep is required */ } return partition; }
v_result v_readerGetSampleLostStatus( v_reader _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(_this != NULL); assert(C_TYPECHECK(_this,v_reader)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { V_READER_LOCK(_this); status = v_entity(_this)->status; result = action(&v_readerStatus(status)->sampleLost, arg); if (reset) { v_statusReset(status, V_EVENT_SAMPLE_LOST); } v_readerStatus(status)->sampleLost.totalChanged = 0; V_READER_UNLOCK(_this); } return result; }
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; }
v_result v_readerGetTopicMatchStatus( v_reader _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(_this != NULL); assert(C_TYPECHECK(_this,v_reader)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { V_READER_LOCK(_this); status = v_entity(_this)->status; result = action(&v_readerStatus(status)->subscriptionMatch, arg); if (reset) { v_statusReset(status, V_EVENT_TOPIC_MATCHED); } v_readerStatus(status)->subscriptionMatch.totalChanged = 0; v_readerStatus(status)->subscriptionMatch.currentChanged = 0; V_READER_UNLOCK(_this); } return result; }
v_result v_readerGetIncompatibleQosStatus( v_reader _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(_this != NULL); assert(C_TYPECHECK(_this,v_reader)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { V_READER_LOCK(_this); status = v_entity(_this)->status; result = action(&v_readerStatus(status)->incompatibleQos, arg); if (reset) { v_statusReset(status, V_EVENT_INCOMPATIBLE_QOS); } v_readerStatus(status)->incompatibleQos.totalChanged = 0; V_READER_UNLOCK(_this); } return result; }
v_result v_readerGetDeadlineMissedStatus( v_reader _this, c_bool reset, v_statusAction action, c_voidp arg) { v_result result; v_status status; assert(_this != NULL); assert(C_TYPECHECK(_this,v_reader)); result = V_RESULT_PRECONDITION_NOT_MET; if (_this != NULL) { V_READER_LOCK(_this); status = v_entity(_this)->status; result = action(&v_readerStatus(status)->deadlineMissed, arg); if (reset) { v_statusReset(status, V_EVENT_DEADLINE_MISSED); } v_readerStatus(status)->deadlineMissed.totalChanged = 0; V_READER_UNLOCK(_this); } return result; }
c_bool v_groupStreamSubscribe( v_groupStream stream, v_partition partition) { c_iter list; v_kernel kernel; c_value params[1]; v_group group; assert(C_TYPECHECK(stream,v_groupStream)); kernel = v_objectKernel(v_entity(partition)); params[0] = c_objectValue(partition); list = v_groupSetSelect(kernel->groupSet,"partition = %0 ",params); group = c_iterTakeFirst(list); while (group != NULL) { v_groupStreamSubscribeGroup(stream, group); c_free(group); group = c_iterTakeFirst(list); } c_iterFree(list); return TRUE; }
/** * PRE: observer must be locked. */ void v_groupStreamNotifyDataAvailable( v_groupStream stream) { /* This Notify method is part of the observer-observable pattern. * It is designed to be invoked when _this object as observer receives * an event from an observable object. * It must be possible to pass the event to the subclass of itself by * calling <subclass>Notify(_this, event, userData). * This implies that _this cannot be locked within any Notify method * to avoid deadlocks. * For consistency _this must be locked by v_observerLock(_this) before * calling this method. */ C_STRUCT(v_event) event; c_bool changed; assert(stream != NULL); assert(C_TYPECHECK(stream,v_groupStream)); changed = v_statusNotifyDataAvailable(v_entity(stream)->status); if (changed) { event.kind = V_EVENT_DATA_AVAILABLE; event.source = v_publicHandle(v_public(stream)); event.userData = NULL; v_observableNotify(v_observable(stream), &event); } return; }
void v_partitionDeinit( v_partition partition) { assert(C_TYPECHECK(partition,v_partition)); v_entityDeinit(v_entity(partition)); }
void v_topicAdapterDeinit( v_topicAdapter adapter) { assert(C_TYPECHECK(adapter,v_topicAdapter)); v_entityDeinit(v_entity(adapter)); }
void SubscriberDelegate::reset_data_on_readers_callback( v_public p, c_voidp arg) { OS_UNUSED_ARG(arg); v_statusReset(v_entity(p)->status, V_EVENT_ON_DATA_ON_READERS); }
/************************************************************** * Public functions **************************************************************/ const c_char * v_serviceGetName( v_service service) { c_char *name = NULL; if ((service != NULL) && (service->state != NULL)) { assert(C_TYPECHECK(service, v_service)); name = v_entity(service->state)->name; } return (const c_char *)name; }
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; }
void cmx_serviceAction( v_entity service, c_voidp args) { assert( (v_object(service)->kind == K_SERVICE) || (v_object(service)->kind == K_SPLICED) || (v_object(service)->kind == K_NETWORKING) || (v_object(service)->kind == K_DURABILITY) || (v_object(service)->kind == K_CMSOAP)); cmx_entityNewFromAction(v_entity(v_service(service)->state), args); }
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; }
c_voidp cmc_entitySetNew( c_iter ventities, c_voidp kernel_uri) { cmc_entitySet entitySet; cmc_entity centity; v_entity entity; entitySet = cmc_entitySet(os_malloc((size_t)(C_SIZEOF(cmc_entitySet)))); entitySet->entities = c_iterNew(NULL); cm_baseObject(entitySet)->kind = CMC_ENTITY_SET; if(ventities != NULL){ entity = v_entity(c_iterTakeFirst(ventities)); while(entity != NULL){ centity = cmc_entity(cmc_entityNew(entity, kernel_uri)); c_iterInsert(entitySet->entities, centity); entity = v_entity(c_iterTakeFirst(ventities)); } } return entitySet; }
static c_bool isGroupMatched( c_string expr, c_voidp args) { char* str; unsigned int partitionLength, topicLength; c_string partition, topic; struct groupMatched* data; data = (struct groupMatched*)args; /* Retrieve partition- & topicname and their lengths */ partition = v_entity(data->group->partition)->name; topic = v_entity(data->group->topic)->name; partitionLength = strlen(partition); topicLength = strlen(topic); /* Allocate temporary string on stack */ str = os_alloca(partitionLength + topicLength + 1 + 1); /* include '.' */ /* Build string */ os_strcpy(str, partition); str[partitionLength] = '.'; os_strcpy(str + partitionLength + 1, topic); /* Match string with pattern */ if(ut_patternMatch(str, expr)) { data->matched = 1; } /* Because not all platforms properly support alloca.. */ os_freea(str); return (!data->matched); }
void v_waitsetFree( v_waitset _this) { v_kernel kernel; v_participant p; assert(_this != NULL); assert(C_TYPECHECK(_this,v_waitset)); kernel = v_objectKernel(_this); p = v_participant(_this->participant); if (p != NULL) { v_participantRemove(p, v_entity(_this)); _this->participant = NULL; } v_observerFree(v_observer(_this)); }
u_result u_topicInit( const u_topic _this, const os_char *name, const v_topicAdapter kt, const u_participant p) { u_result result; assert(_this != NULL); assert(name != NULL); result = u_entityInit(u_entity(_this),v_entity(kt), u_observableDomain(u_observable(p))); if (result == U_RESULT_OK) { _this->name = os_strdup(name); _this->participant = p; } return result; }
v_result v_readerSetQos( v_reader r, v_readerQos qos) { v_result result; v_qosChangeMask cm; assert(C_TYPECHECK(r,v_reader)); v_readerEntrySetLock(r); result = v_readerQosSet(r->qos, qos, v_entity(r)->enabled, &cm); v_readerEntrySetUnlock(r); if ((result == V_RESULT_OK) && (cm != 0)) { if (v_objectKind(r) == K_DATAREADER) { v_dataReaderNotifyChangedQos(v_dataReader(r)); } } return result; }