Esempio n. 1
0
static Endpoint_t *create_builtin_reader (Domain_t       *dp,
					  Builtin_Type_t type,
					  const char     *topic_name,
					  const char     *type_name)
{
	TopicType_t	*typep;
	Topic_t		*tp;
	Reader_t	*rp;
	DDS_TopicQos	qos_data;

	typep = type_create (dp, type_name, NULL);
	if (!typep)
		return (NULL);

	typep->flags = EF_LOCAL | EF_BUILTIN;
	typep->index = type;
	tp = topic_create (&dp->participant, NULL, topic_name, type_name, NULL);
	if (!tp)
		return (NULL);

	tp->entity.flags |= EF_ENABLED | EF_BUILTIN | EF_NOT_IGNORED;
	qos_data = qos_def_topic_qos;
	qos_data.durability.kind = DDS_TRANSIENT_LOCAL_DURABILITY_QOS;
	qos_data.reliability.kind = DDS_RELIABLE_RELIABILITY_QOS;
	tp->qos = qos_topic_new (&qos_data);
	if (!tp->qos) {
		topic_delete (&dp->participant, tp, NULL, NULL);
		return (NULL);
	}

	rp = DDS_Subscriber_create_datareader (dp->builtin_subscriber,
					       (DDS_TopicDescription) tp,
					       DDS_DATAREADER_QOS_USE_TOPIC_QOS,
					       NULL, 0);
	if (!rp) {
		topic_delete (&dp->participant, tp, NULL, NULL);
		return (NULL);
	}
	dp->builtin_readers [type] = rp;

#ifdef RTPS_USED
	if (rtps_used)
		disc_populate_builtin (dp, type);
#endif
	return (&rp->r_ep);
}
Esempio n. 2
0
static void delete_builtin_reader (Domain_t       *dp,
				   Builtin_Type_t type,
				   Topic_t        *tp)
{
	/* Remove the cache reference. */
	dp->builtin_readers [type] = NULL;

	/* Delete the builtin datareader. */
	DDS_Subscriber_delete_datareader ((DDS_Subscriber) dp->builtin_subscriber,
					  (DDS_DataReader) tp->readers);

	/* Delete builtin topic. */
	lock_take (tp->lock);
	topic_delete (&dp->participant, tp, NULL, NULL);
}
Esempio n. 3
0
DDS_ReturnCode_t DDS_DomainParticipant_delete_topic (DDS_DomainParticipant dp,
						     DDS_Topic             tp)
{
	DDS_ReturnCode_t	ret;
	Condition_t		*cp;

	ctrc_begind (DCPS_ID, DCPS_DP_D_TOP, &dp, sizeof (dp));
	ctrc_contd (&tp, sizeof (tp));
	ctrc_endd ();

	prof_start (dcps_delete_topic_p);

	/* Get Domain Participant. */
	if (!domain_ptr (dp, 1, &ret)) {
		log_printf (DCPS_ID, 0, "dcps_delete_topic(): domain participant not found!\r\n");
		return (ret);
	}

	/* Get Topic descriptor. */
	if (!topic_ptr (tp, 0, &ret)) {
		lock_release (dp->lock);
		return (ret);
	}
	if ((tp->entity.flags & EF_FILTERED) != 0) {
		lock_release (dp->lock);
		return (DDS_RETCODE_PRECONDITION_NOT_MET);
	}
	if (tp->domain != dp || (!tp->nlrefs && !tp->nrrefs)) {
		log_printf (DCPS_ID, 0, "dcps_delete_topic(): invalid topic!\r\n");
		lock_release (dp->lock);
		return (DDS_RETCODE_ALREADY_DELETED);
	}
	lock_take (tp->lock);

	/* If not the last topic reference, just update the reference count. */
	if (tp->nlrefs > 1 || !tp->nlrefs) {
		if (tp->nlrefs)
			tp->nlrefs--;
		lock_release (tp->lock);
		lock_release (dp->lock);
		return (DDS_RETCODE_OK);
	}

	/* Check if there are still references, i.e. local readers/writers, of
	   this topic. */
	if (local_endpoints (tp->readers) || local_endpoints (tp->writers)) {
		log_printf (DCPS_ID, 0, "dcps_delete_topic(%s): still endpoints using topic!\r\n", str_ptr (tp->name));
		lock_release (tp->lock);
		lock_release (dp->lock);
		return (DDS_RETCODE_PRECONDITION_NOT_MET);
	}

	/* Last local reference.  Disable event propagation to topic. */
	if (!dds_purge_notifications ((Entity_t *) tp, DDS_ALL_STATUS, 1)) {
		lock_release (tp->lock);
		lock_release (dp->lock);
		return (DDS_RETCODE_PRECONDITION_NOT_MET);
	}
	tp->entity.flags &= ~EF_ENABLED;

	/* Delete topic notification data. */
	memset (&tp->listener, 0, sizeof (tp->listener));
	tp->mask = 0;

	/* Delete StatusCondition if it exists. */
	if (tp->condition) {
		cp = (Condition_t *) tp->condition;
		if (cp->deferred)
			dds_defer_waitset_undo (tp, tp->condition);
		dcps_delete_status_condition (tp->condition);
		tp->condition = NULL;
	}

	/* Delete topic data. */
	topic_delete (&dp->participant, tp, NULL, NULL);

	lock_release (dp->lock);
	prof_stop (dcps_delete_topic_p, 1);
	return (DDS_RETCODE_OK);
}