static u_result handlePublication( u_dataReader dataReader, c_long dataOffset, u_dataReader pDataReader, c_long pDataOffset) { v_dataReaderSample sample; u_result result; v_state state; v_message msg; struct v_publicationInfo *data; in_writer writer; in_participant participant; sample = NULL; result = u_dataReaderTake(dataReader, takeOne, &sample); while(sample && (result == U_RESULT_OK)){ state = v_readerSample(sample)->sampleState; msg = v_dataReaderSampleMessage(sample); data = (struct v_publicationInfo *)(C_DISPLACE(msg, dataOffset)); os_mutexLock (&gluelock); if(v_stateTest(state, L_DISPOSED)){ writer = in_writerLookup(&data->key); if(writer){ in_writerFree(writer, NULL); } else { nn_log (LC_WARNING, "handlePublication: disposed writer not found\n"); /*abort();*/ } } else { participant = in_participantLookup(&(data->participant_key)); if(!participant){ result = handleParticipant(pDataReader, pDataOffset, 1); if(result == U_RESULT_OK){ participant = in_participantLookup(&(data->participant_key)); } } if(participant){ in_writerNew(participant, data); } else { nn_log (LC_ERROR, "handlePublication: participant not found\n"); result = U_RESULT_INTERNAL_ERROR; /*abort();*/ } } os_mutexUnlock (&gluelock); c_free(sample); sample = NULL; result = u_dataReaderTake(dataReader, takeOne, &sample); } return result; }
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; }
static u_result handleParticipant( u_dataReader dataReader, c_long dataOffset, int gluelockAlreadyHeld) { v_dataReaderSample sample; u_result result; v_state state; v_message msg; struct v_participantInfo *data; in_participant participant; sample = NULL; result = u_dataReaderTake(dataReader, takeOne, &sample); while(sample && (result == U_RESULT_OK)){ state = v_readerSample(sample)->sampleState; msg = v_dataReaderSampleMessage(sample); data = (struct v_participantInfo *)(C_DISPLACE(msg, dataOffset)); if (!gluelockAlreadyHeld) os_mutexLock (&gluelock); if(v_stateTest(state, L_DISPOSED)){ participant = in_participantLookup(&(data->key)); if(participant){ in_participantFree(participant, NULL); } } else { in_participantNew(data); } if (!gluelockAlreadyHeld) os_mutexUnlock (&gluelock); c_free(sample); sample = NULL; result = u_dataReaderTake(dataReader, takeOne, &sample); } return result; }