Give all entities an instance handle (#43)

Add the instance handle to the DDSC entity type, initialize it properly
for all types, and remove the per-type handling of
dds_get_instance_handle.  Those entities that have a DDSI variant take
the instance handle from DDSI (which plays tricks to get the instance
handles of the entities matching the built-in topics).  For those that
do not have a DDSI variant, just generate a unique identifier using the
same generate that DDSI uses.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-06-08 19:23:53 +02:00 committed by eboasson
parent 9c2f3bdf2b
commit 28317ba49e
16 changed files with 70 additions and 134 deletions

View file

@ -529,6 +529,7 @@ dds_return_t new_participant (struct nn_guid *ppguid, unsigned flags, const stru
*/
dds_return_t delete_participant (const struct nn_guid *ppguid);
void update_participant_plist (struct participant *pp, const struct nn_plist *plist);
uint64_t get_entity_instance_id (const struct nn_guid *guid);
/* To obtain the builtin writer to be used for publishing SPDP, SEDP,
PMD stuff for PP and its endpoints, given the entityid. If PP has
@ -559,7 +560,6 @@ dds_return_t delete_writer_nolinger (const struct nn_guid *guid);
dds_return_t delete_writer_nolinger_locked (struct writer *wr);
dds_return_t delete_reader (const struct nn_guid *guid);
uint64_t reader_instance_id (const struct nn_guid *guid);
struct local_orphan_writer {
struct writer wr;
@ -593,7 +593,6 @@ void delete_local_orphan_writer (struct local_orphan_writer *wr);
void new_proxy_participant (const struct nn_guid *guid, unsigned bes, unsigned prismtech_bes, const struct nn_guid *privileged_pp_guid, struct addrset *as_default, struct addrset *as_meta, const struct nn_plist *plist, dds_duration_t tlease_dur, nn_vendorid_t vendor, unsigned custom_flags, nn_wctime_t timestamp, seqno_t seq);
int delete_proxy_participant_by_guid (const struct nn_guid * guid, nn_wctime_t timestamp, int isimplicit);
uint64_t participant_instance_id (const struct nn_guid *guid);
enum update_proxy_participant_source {
UPD_PROXYPP_SPDP,
@ -629,8 +628,6 @@ void update_proxy_writer (struct proxy_writer *pwr, struct addrset *as, const st
int new_proxy_group (const struct nn_guid *guid, const char *name, const struct dds_qos *xqos, nn_wctime_t timestamp);
void delete_proxy_group (const struct nn_guid *guid, nn_wctime_t timestamp, int isimplicit);
uint64_t writer_instance_id (const struct nn_guid *guid);
/* Call this to empty all address sets of all writers to stop all outgoing traffic, or to
rebuild them all (which only makes sense after previously having emptied them all). */
void rebuild_or_clear_writer_addrsets(int rebuild);

View file

@ -3124,20 +3124,6 @@ dds_return_t delete_writer (const struct nn_guid *guid)
return 0;
}
uint64_t writer_instance_id (const struct nn_guid *guid)
{
struct entity_common *e;
e = (struct entity_common*)ephash_lookup_writer_guid(guid);
if (e) {
return e->iid;
}
e = (struct entity_common*)ephash_lookup_proxy_writer_guid(guid);
if (e) {
return e->iid;
}
return 0;
}
/* READER ----------------------------------------------------------- */
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
@ -3464,20 +3450,6 @@ dds_return_t delete_reader (const struct nn_guid *guid)
return 0;
}
uint64_t reader_instance_id (const struct nn_guid *guid)
{
struct entity_common *e;
e = (struct entity_common*)ephash_lookup_reader_guid(guid);
if (e) {
return e->iid;
}
e = (struct entity_common*)ephash_lookup_proxy_reader_guid(guid);
if (e) {
return e->iid;
}
return 0;
}
void update_reader_qos (struct reader *rd, const dds_qos_t *xqos)
{
ddsrt_mutex_lock (&rd->e.lock);
@ -3967,18 +3939,16 @@ int delete_proxy_participant_by_guid (const struct nn_guid * guid, nn_wctime_t t
return 0;
}
uint64_t participant_instance_id (const struct nn_guid *guid)
uint64_t get_entity_instance_id (const struct nn_guid *guid)
{
struct entity_common *e;
e = (struct entity_common*)ephash_lookup_participant_guid(guid);
if (e) {
return e->iid;
}
e = (struct entity_common*)ephash_lookup_proxy_participant_guid(guid);
if (e) {
return e->iid;
}
return 0;
struct thread_state1 *ts1 = lookup_thread_state ();
struct entity_common *e;
uint64_t iid = 0;
thread_state_awake (ts1);
if ((e = ephash_lookup_guid_untyped (guid)) != NULL)
iid = e->iid;
thread_state_asleep (ts1);
return iid;
}
/* PROXY-GROUP --------------------------------------------------- */

View file

@ -121,6 +121,7 @@ void *ephash_lookup_guid_untyped (const struct nn_guid *guid)
/* FIXME: could (now) require guid to be first in entity_common; entity_common already is first in entity */
struct entity_common e;
e.guid = *guid;
assert (thread_is_awake ());
return ddsrt_chh_lookup (gv.guid_hash->hash, &e);
}

View file

@ -542,9 +542,9 @@ void xeventq_free (struct xeventq *evq)
handle_nontimed_xevent (getnext_from_non_timed_xmit_list (evq), xp);
}
ddsrt_mutex_unlock (&evq->lock);
thread_state_asleep (lookup_thread_state ());
nn_xpack_send (xp, false);
nn_xpack_free (xp);
thread_state_asleep (lookup_thread_state ());
}
assert (ddsrt_avl_is_empty (&evq->msg_xevents));