Beispiel #1
0
DDS_ReturnCode_t DDS_Topic_set_qos (DDS_Topic tp, DDS_TopicQos *qos)
{
	Endpoint_t		*ep;
	Reader_t		*rp;
	Writer_t		*wp;
	DDS_ReturnCode_t	ret;

	ctrc_begind (DCPS_ID, DCPS_T_S_QOS, &tp, sizeof (tp));
	ctrc_contd (&qos, sizeof (qos));
	ctrc_endd ();

	if (!topic_ptr (tp, 1, &ret))
		return (ret);

	if (qos == DDS_TOPIC_QOS_DEFAULT)
		qos = &tp->domain->def_topic_qos;
	else if (!qos_valid_topic_qos (qos)) {
		ret = DDS_RETCODE_BAD_PARAMETER;
		goto done;
	}
	ret = qos_topic_update (&tp->qos, qos);
	if (ret != DDS_RETCODE_OK)
		goto done;

	/* Update all local Readers associated with topic. */
	for (ep = tp->readers; ep; ep = ep->next)
		if ((ep->entity.flags & EF_LOCAL) != 0) {
			rp = (Reader_t *) ep;
#ifdef RW_LOCKS
			lock_take (rp->r_lock);
#endif
			disc_reader_update (tp->domain, rp, 1, 0);
#ifdef RW_LOCKS
			lock_release (rp->r_lock);
#endif
		}

	/* Update all local Writers associated with topic. */
	for (ep = tp->writers; ep; ep = ep->next)
		if ((ep->entity.flags & EF_LOCAL) != 0) {
			wp = (Writer_t *) ep;
#ifdef RW_LOCKS
			lock_take (wp->w_lock);
#endif
			disc_writer_update (tp->domain, wp, 1, 0);
#ifdef RW_LOCKS
			lock_release (wp->w_lock);
#endif
		}

    done:
    	lock_release (tp->lock);
	return (ret);
}
Beispiel #2
0
DDS_ReturnCode_t DDS_DomainParticipant_set_default_topic_qos (DDS_DomainParticipant dp,
							      DDS_TopicQos          *qos)
{
	DDS_ReturnCode_t	ret = DDS_RETCODE_OK;

	ctrc_begind (DCPS_ID, DCPS_DP_S_T_QOS, &dp, sizeof (dp));
	ctrc_contd (&qos, sizeof (qos));
	ctrc_endd ();

	/* Get Domain Participant. */
	if (!domain_ptr (dp, 1, &ret)) {
		log_printf (DCPS_ID, 0, "set_default_topic_qos: domain doesn't exist!\r\n");
		return (DDS_RETCODE_ALREADY_DELETED);
	}
	if (qos == DDS_TOPIC_QOS_DEFAULT)
		dp->def_topic_qos = qos_def_topic_qos;
	else if (qos_valid_topic_qos (qos))
		dp->def_topic_qos = *qos;
	else
		ret = DDS_RETCODE_INCONSISTENT_POLICY;

	lock_release (dp->lock);
	return (ret);
}
Beispiel #3
0
DDS_Topic DDS_DomainParticipant_create_topic (DDS_DomainParticipant   dp,
					      const char              *topic_name,
					      const char              *type_name,
					      const DDS_TopicQos      *qos,
					      const DDS_TopicListener *listener,
					      DDS_StatusMask          mask)
{
	Topic_t		*tp;
	int		new_topic;

	ctrc_begind (DCPS_ID, DCPS_DP_C_TOP, &dp, sizeof (dp));
	ctrc_contd (topic_name, strlen (topic_name) + 1);
	ctrc_contd (type_name, strlen (type_name) + 1);
	ctrc_contd (&qos, sizeof (qos));
	ctrc_contd (&listener, sizeof (listener));
	ctrc_contd (&mask, sizeof (mask));
	ctrc_endd ();

	prof_start (dcps_create_topic);

	/* Get Domain Participant. */
	if (!domain_ptr (dp, 1, NULL)) {
		log_printf (DCPS_ID, 0, "create_topic(%s): domain doesn't exist!\r\n", topic_name);
		return (NULL);
	}
	if (qos == DDS_TOPIC_QOS_DEFAULT)
		qos = &dp->def_topic_qos;
	else if (!qos_valid_topic_qos (qos)) {
		log_printf (DCPS_ID, 0, "create_topic(%s): invalid topic QoS!\r\n", topic_name);
		lock_release (dp->lock);
		return (NULL);
	}

#ifdef DDS_SECURITY

	/* Check if security policy allows this topic. */
	if (check_create_topic (dp->participant.p_permissions, topic_name, qos)) {
		log_printf (DCPS_ID, 0, "create_topic(%s): topic create not allowed!\r\n", topic_name);
		lock_release (dp->lock);
		return (NULL);
	}
#endif

	/* New topic: create topic context. */
	tp = topic_create (&dp->participant, NULL, topic_name, type_name, &new_topic);
	if (!tp) {
		log_printf (DCPS_ID, 0, "create_topic (%s): out of memory for topic!\r\n", topic_name);
		lock_release (dp->lock);
		return (NULL);
	}

	/* Set Qos fields appropriately. */
	if (new_topic)
		tp->qos = qos_topic_new (qos);
	else if (tp->nlrefs == 1) /* First real QoS setting. */
		qos_topic_update (&tp->qos, qos);

	/* Check if the supplied listener can be set on the topic. Ok, if no
	   listener was previously set or the supplied listener is the same as
	   the previously set listener. */
	if (listener) {
		if (!new_topic && 
		    memcmp (&tp->listener, listener, sizeof (tp->listener)))
			log_printf (DCPS_ID, 0, "create_topic(%s): existing listener updated!\r\n", topic_name);
		tp->listener = *listener;
	}

	/* Check if the mask is the same. */
	if (!new_topic && mask && mask != tp->mask)
		log_printf (DCPS_ID, 0, "create_topic(%s): existing mask updated!\r\n", topic_name);

	tp->mask = mask;
	lock_release (dp->lock);

	if (dp->autoenable)
		DDS_Topic_enable ((DDS_Topic) tp);

	prof_stop (dcps_create_topic, 1);

	return (tp);
}