void serviceStateExpired( v_leaseAction leaseAction) { v_object o; v_handleResult r; assert(leaseAction != NULL); assert(C_TYPECHECK(leaseAction, v_leaseAction)); r = v_handleClaim(leaseAction->actionObject, &o); if (r == V_HANDLE_OK) { if (o->kind == K_SERVICESTATE) { v_serviceStateChangeState(v_serviceState(o), STATE_DIED); } else { OS_REPORT_1(OS_WARNING, "v_leaseManager", 0, "Lease action on unexpected object type: %d", o->kind); } 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 just skip, since entity is already gone */ }
DDS::ReturnCode_t DDS::OpenSplice::Utils::copyStatusOut( const v_deadlineMissedInfo &from, DDS::OfferedDeadlineMissedStatus &to) { DDS::ReturnCode_t result; v_object instance; result = DDS::RETCODE_ERROR; to.total_count = from.totalCount; to.total_count_change = from.totalChanged; if (!v_handleIsNil(from.instanceHandle)) { if (v_handleClaim(from.instanceHandle, &instance) == V_HANDLE_OK) { to.last_instance_handle = u_instanceHandleNew(v_public(instance)); if (v_handleRelease(from.instanceHandle) == V_HANDLE_OK) { result = DDS::RETCODE_OK; } } } else { result = DDS::RETCODE_OK; } return result; }
u_result u_instanceHandleClaim ( u_instanceHandle _this, c_voidp instance) { u_result result; v_handle handle; u_instanceHandleTranslator translator; if (instance == NULL) { result = U_RESULT_ILL_PARAM; } else if (_this == 0) { result = U_RESULT_ILL_PARAM; } else { translator.handle = _this; handle.serial = (translator.lid.lifecycleId & HANDLE_SERIAL_MASK); handle.index = translator.lid.localId; handle.server = u_userServer(translator.lid.lifecycleId & HANDLE_SERVER_MASK); result = u__handleResult(v_handleClaim(handle,instance)); } return result; }
void heartbeatCheck( v_leaseAction leaseAction) { v_object sd; v_handleResult r; assert(leaseAction != NULL); assert(C_TYPECHECK(leaseAction, v_leaseAction)); r = v_handleClaim(leaseAction->actionObject, &sd); if (r == V_HANDLE_OK) { v_splicedCheckHeartbeats(v_spliced(sd)); 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 { OS_REPORT(OS_ERROR, "heartbeatSend", 0, "Could not claim the splicedaemon!"); } }
void splicedDeathDetected( v_leaseAction leaseAction) { v_object o; v_kernel kernel; v_handleResult r; assert(leaseAction != NULL); assert(C_TYPECHECK(leaseAction, v_leaseAction)); r = v_handleClaim(leaseAction->actionObject, &o); if (r == V_HANDLE_OK) { kernel = v_kernel(o); kernel->splicedRunning = FALSE; 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 just skip, since entity is already gone */ }
u_result u_handleClaim ( u_handle _this, c_voidp instance) { return u__handleResult (v_handleClaim (_this, instance)); }
v_public v_gidClaim ( v_gid id, v_kernel kernel) { v_handle handle; v_object o = NULL; if (v_gidIsFromKernel(id, kernel)) { handle = gidToHandle(id,kernel); v_handleClaim(handle, &o); /* Ignore result */ assert(C_TYPECHECK(o,v_public)); } return v_public(o); }
static void printStructure( c_structure _this, toolActionData actionData) { c_object o; c_object object; c_long i, size; c_member member; o = c_iterObject(actionData->stack, 0); if (o) { if (c_iterLength(actionData->stack) == 1) { printf("%s ", _METANAME(_this)); } else { } printf("{\n"); size = c_structureMemberCount(_this); for (i=0; i<size; i++) { member = c_structureMember(_this, i); object = C_DISPLACE(o, (c_address)member->offset); if (c_typeIsRef(c_memberType(member))) { iprintf(" %s <0x"PA_ADDRFMT">\n", c_specifierName(member), *(os_address *)object); } else { OBJECT_PUSH(actionData, object); iprintf("%s ",c_specifierName(member)); printType(c_memberType(member), actionData); printf("\n"); OBJECT_POP(actionData); } } if (c_iterLength(actionData->stack) == 1) { iprintf("};"); } else { iprintf("} %s;", _METANAME(_this)); } if (c_type(_this) == v_handle_t) { v_object vo; v_handleClaim(*(v_handle *)o,&vo); v_handleRelease(*(v_handle *)o); printf(" /* Handle's object: <0x"PA_ADDRFMT"> */", (os_address)vo); } } }
/* Do not use C_TYPECHECK on qos parameter, since it might be allocated on heap! */ kernel = v_objectKernel(p); c_lockWrite(&p->lock); result = v_participantQosSet(p->qos, qos, &cm); if ((result == V_RESULT_OK) && (cm != 0)) { builtinMsg = v_builtinCreateParticipantInfo(kernel->builtin,p); c_lockUnlock(&p->lock); v_writeBuiltinTopic(kernel, V_PARTICIPANTINFO_ID, builtinMsg); c_free(builtinMsg); } else { c_lockUnlock(&p->lock); } return result; } v_leaseManager v_participantGetLeaseManager( v_participant p) { assert(C_TYPECHECK(p,v_participant)); return c_keep(p->leaseManager); } #define RESEND_SECS (0U) #define RESEND_NANOSECS (2000000U) /* 2 ms */ void v_participantResendManagerMain( v_participant p) { c_iter writerProxies; v_proxy wp; v_writer w; v_handleResult r; c_time waitTime = { RESEND_SECS, RESEND_NANOSECS }; assert(C_TYPECHECK(p,v_participant)); c_mutexLock(&p->resendMutex); while (!p->resendQuit) { if (c_count(p->resendWriters) == 0) { c_condWait(&p->resendCond, &p->resendMutex); } else { c_condTimedWait(&p->resendCond, &p->resendMutex, waitTime); } if (!p->resendQuit) { writerProxies = c_select(p->resendWriters, 0); c_mutexUnlock(&p->resendMutex); wp = v_proxy(c_iterTakeFirst(writerProxies)); while (wp != NULL) { r = v_handleClaim(wp->source,(v_object *)&w); if (r == V_HANDLE_OK) { assert(C_TYPECHECK(w,v_writer)); v_writerResend(w); v_handleRelease(wp->source); } c_free(wp); wp = v_proxy(c_iterTakeFirst(writerProxies)); } c_iterFree(writerProxies); c_mutexLock(&p->resendMutex); } /* already quiting */ } c_mutexUnlock(&p->resendMutex); }
void v_waitsetDeinit( v_waitset _this) { v_waitsetEvent event; v_observable o; v_proxy found; v_handleResult result; void* userDataRemoved = NULL; assert(_this != NULL); assert(C_TYPECHECK(_this,v_waitset)); if (_this == NULL) { return; } v_waitsetLock(_this); found = c_take(_this->observables); while (found) { result = v_handleClaim(found->source,(v_object *)&o); if (result == V_HANDLE_OK) { v_observableRemoveObserver(o,v_observer(_this), &userDataRemoved); v_waitsetClearRemovedObserverPendingEvents(_this, userDataRemoved); result = v_handleRelease(found->source); } c_free(found); found = c_take(_this->observables); } /* wakeup blocking threads to evaluate new condition. */ /* remove all events */ while (v_waitsetEvent(v_waitsetEventList(_this)) != NULL) { event = v_waitsetEvent(v_waitsetEventList(_this)); v_waitsetEventList(_this) = event->next; event->next = NULL; c_free(event); } v_waitsetWakeup(_this, NULL, NULL); v_waitsetUnlock(_this); v_observerDeinit(v_observer(_this)); }
static v_result copy_deadline_missed_status( c_voidp info, c_voidp arg) { struct v_deadlineMissedInfo *from; gapi_offeredDeadlineMissedStatus *to; v_handleResult result; v_public instance; from = (struct v_deadlineMissedInfo *)info; to = (gapi_offeredDeadlineMissedStatus *)arg; to->total_count = from->totalCount; to->total_count_change = from->totalChanged; result = v_handleClaim(from->instanceHandle, (v_object *) &instance); if (result == V_HANDLE_OK) { to->last_instance_handle = u_instanceHandleNew(v_public(instance)); result = v_handleRelease(from->instanceHandle); } return V_RESULT_OK; }
void writerDeadlineMissed( v_leaseAction leaseAction, c_time now) { v_object w; v_handleResult r; assert(leaseAction != NULL); assert(C_TYPECHECK(leaseAction, v_leaseAction)); r = v_handleClaim(leaseAction->actionObject, &w); if (r == V_HANDLE_OK) { v_writerCheckDeadlineMissed(v_writer(w), now); 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); } } }
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); } }
d_readerRequest d_readerRequestNew( d_admin admin, v_handle source, c_char* filter, c_char** filterParams, c_long filterParamsCount, struct v_resourcePolicy resourceLimits, c_time minSourceTimestamp, c_time maxSourceTimestamp) { d_readerRequest request; c_long i; v_handleResult handleResult; v_reader vreader, *vreaderPtr; c_iter partitions; v_partition partition; v_topic topic; d_group dgroup; c_char *topicName; d_quality quality; request = d_readerRequest(os_malloc(C_SIZEOF(d_readerRequest))); if(request){ d_lockInit(d_lock(request), D_READER_REQUEST, d_readerRequestDeinit); request->admin = admin; request->readerHandle.index = source.index; request->readerHandle.serial = source.serial; request->readerHandle.server = source.server; request->requests = d_tableNew(d_chainCompare, d_chainFree); if(filter){ request->filter = os_strdup(filter); } else { request->filter = NULL; } request->resourceLimits = resourceLimits; request->minSourceTimestamp = minSourceTimestamp; request->maxSourceTimestamp = maxSourceTimestamp; request->filterParamsCount = filterParamsCount; if(filterParamsCount > 0){ request->filterParams = (c_char**)(os_malloc( filterParamsCount*sizeof(c_char*))); for(i=0; i<filterParamsCount; i++){ request->filterParams[i] = os_strdup(filterParams[i]); } } else { request->filterParams = NULL; } request->groups = d_tableNew(d_groupCompare, d_groupFree); handleResult = v_handleClaim(source, (v_object*)(vreaderPtr = &vreader)); if(handleResult == V_HANDLE_OK){ if(v_object(vreader)->kind == K_DATAREADER){ topic = v_dataReaderGetTopic(v_dataReader(vreader)); topicName = v_entity(topic)->name; partitions = ospl_c_select(v_subscriber(vreader->subscriber)->partitions->partitions, 0); partition = v_partition(c_iterTakeFirst(partitions)); while(partition){ quality.seconds = 0; quality.nanoseconds = 0; dgroup = d_groupNew( v_entity(partition)->name, topicName, topic->qos->durability.kind, D_GROUP_KNOWLEDGE_UNDEFINED, quality); d_tableInsert(request->groups, dgroup); c_free(partition); partition = v_partition(c_iterTakeFirst(partitions)); } c_free(topic); } else { d_readerRequestFree(request); request = NULL; } v_handleRelease(source); } else { d_readerRequestFree(request); request = NULL; } } return request; }