Store logcfg in deleted_participants_admin

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-09-10 15:52:30 +02:00 committed by eboasson
parent 68e3e55c2f
commit d9dac3b7e2
3 changed files with 10 additions and 8 deletions

View file

@ -400,7 +400,7 @@ extern const ddsrt_avl_treedef_t deleted_participants_treedef;
#define DPG_LOCAL 1 #define DPG_LOCAL 1
#define DPG_REMOTE 2 #define DPG_REMOTE 2
struct deleted_participants_admin; struct deleted_participants_admin;
struct deleted_participants_admin *deleted_participants_admin_new (int64_t delay); struct deleted_participants_admin *deleted_participants_admin_new (const ddsrt_log_cfg_t *logcfg, int64_t delay);
void deleted_participants_admin_free (struct deleted_participants_admin *admin); void deleted_participants_admin_free (struct deleted_participants_admin *admin);
int is_deleted_participant_guid (struct deleted_participants_admin *admin, const struct ddsi_guid *guid, unsigned for_what); int is_deleted_participant_guid (struct deleted_participants_admin *admin, const struct ddsi_guid *guid, unsigned for_what);

View file

@ -59,6 +59,7 @@ struct deleted_participant {
struct deleted_participants_admin { struct deleted_participants_admin {
ddsrt_mutex_t deleted_participants_lock; ddsrt_mutex_t deleted_participants_lock;
ddsrt_avl_tree_t deleted_participants; ddsrt_avl_tree_t deleted_participants;
const ddsrt_log_cfg_t *logcfg;
int64_t delay; int64_t delay;
}; };
@ -311,11 +312,12 @@ void ddsi_make_writer_info(struct ddsi_writer_info *wrinfo, const struct entity_
/* DELETED PARTICIPANTS --------------------------------------------- */ /* DELETED PARTICIPANTS --------------------------------------------- */
struct deleted_participants_admin *deleted_participants_admin_new (int64_t delay) struct deleted_participants_admin *deleted_participants_admin_new (const ddsrt_log_cfg_t *logcfg, int64_t delay)
{ {
struct deleted_participants_admin *admin = ddsrt_malloc (sizeof (*admin)); struct deleted_participants_admin *admin = ddsrt_malloc (sizeof (*admin));
ddsrt_mutex_init (&admin->deleted_participants_lock); ddsrt_mutex_init (&admin->deleted_participants_lock);
ddsrt_avl_init (&deleted_participants_treedef, &admin->deleted_participants); ddsrt_avl_init (&deleted_participants_treedef, &admin->deleted_participants);
admin->logcfg = logcfg;
admin->delay = delay; admin->delay = delay;
return admin; return admin;
} }
@ -339,6 +341,7 @@ static void prune_deleted_participant_guids_unlocked (struct deleted_participant
struct deleted_participant *dpp1 = ddsrt_avl_find_succ (&deleted_participants_treedef, &admin->deleted_participants, dpp); struct deleted_participant *dpp1 = ddsrt_avl_find_succ (&deleted_participants_treedef, &admin->deleted_participants, dpp);
if (dpp->t_prune.v < tnow.v) if (dpp->t_prune.v < tnow.v)
{ {
DDS_CLOG (DDS_LC_DISCOVERY, admin->logcfg, "prune_deleted_participant_guid("PGUIDFMT")\n", PGUID (dpp->guid));
ddsrt_avl_delete (&deleted_participants_treedef, &admin->deleted_participants, dpp); ddsrt_avl_delete (&deleted_participants_treedef, &admin->deleted_participants, dpp);
ddsrt_free (dpp); ddsrt_free (dpp);
} }
@ -385,17 +388,16 @@ int is_deleted_participant_guid (struct deleted_participants_admin *admin, const
return known; return known;
} }
static void remove_deleted_participant_guid (ddsrt_log_cfg_t *logcfg, struct deleted_participants_admin *admin, const struct ddsi_guid *guid, unsigned for_what) static void remove_deleted_participant_guid (struct deleted_participants_admin *admin, const struct ddsi_guid *guid, unsigned for_what)
{ {
struct deleted_participant *n; struct deleted_participant *n;
DDS_CLOG (DDS_LC_DISCOVERY, logcfg, "remove_deleted_participant_guid("PGUIDFMT" for_what=%x)\n", PGUID (*guid), for_what); DDS_CLOG (DDS_LC_DISCOVERY, admin->logcfg, "remove_deleted_participant_guid("PGUIDFMT" for_what=%x)\n", PGUID (*guid), for_what);
ddsrt_mutex_lock (&admin->deleted_participants_lock); ddsrt_mutex_lock (&admin->deleted_participants_lock);
if ((n = ddsrt_avl_lookup (&deleted_participants_treedef, &admin->deleted_participants, guid)) != NULL) if ((n = ddsrt_avl_lookup (&deleted_participants_treedef, &admin->deleted_participants, guid)) != NULL)
n->t_prune = add_duration_to_mtime (now_mt (), admin->delay); n->t_prune = add_duration_to_mtime (now_mt (), admin->delay);
ddsrt_mutex_unlock (&admin->deleted_participants_lock); ddsrt_mutex_unlock (&admin->deleted_participants_lock);
} }
/* PARTICIPANT ------------------------------------------------------ */ /* PARTICIPANT ------------------------------------------------------ */
static bool update_qos_locked (struct entity_common *e, dds_qos_t *ent_qos, const dds_qos_t *xqos, nn_wctime_t timestamp) static bool update_qos_locked (struct entity_common *e, dds_qos_t *ent_qos, const dds_qos_t *xqos, nn_wctime_t timestamp)
@ -898,7 +900,7 @@ static void unref_participant (struct participant *pp, const struct ddsi_guid *g
ddsrt_free (pp->plist); ddsrt_free (pp->plist);
ddsrt_mutex_destroy (&pp->refc_lock); ddsrt_mutex_destroy (&pp->refc_lock);
entity_common_fini (&pp->e); entity_common_fini (&pp->e);
remove_deleted_participant_guid (&pp->e.gv->logconfig, pp->e.gv->deleted_participants, &pp->e.guid, DPG_LOCAL); remove_deleted_participant_guid (pp->e.gv->deleted_participants, &pp->e.guid, DPG_LOCAL);
inverse_uint32_set_fini(&pp->avail_entityids.x); inverse_uint32_set_fini(&pp->avail_entityids.x);
ddsrt_free (pp); ddsrt_free (pp);
} }
@ -3834,7 +3836,7 @@ static void unref_proxy_participant (struct proxy_participant *proxypp, struct p
if (proxypp->owns_lease) if (proxypp->owns_lease)
lease_free (ddsrt_atomic_ldvoidp (&proxypp->lease)); lease_free (ddsrt_atomic_ldvoidp (&proxypp->lease));
entity_common_fini (&proxypp->e); entity_common_fini (&proxypp->e);
remove_deleted_participant_guid (&proxypp->e.gv->logconfig, proxypp->e.gv->deleted_participants, &proxypp->e.guid, DPG_LOCAL | DPG_REMOTE); remove_deleted_participant_guid (proxypp->e.gv->deleted_participants, &proxypp->e.guid, DPG_LOCAL | DPG_REMOTE);
ddsrt_free (proxypp); ddsrt_free (proxypp);
} }
else if (proxypp->endpoints == NULL && proxypp->implicitly_created) else if (proxypp->endpoints == NULL && proxypp->implicitly_created)

View file

@ -1027,7 +1027,7 @@ int rtps_init (struct q_globals *gv)
ddsrt_mutex_init (&gv->participant_set_lock); ddsrt_mutex_init (&gv->participant_set_lock);
ddsrt_cond_init (&gv->participant_set_cond); ddsrt_cond_init (&gv->participant_set_cond);
lease_management_init (gv); lease_management_init (gv);
gv->deleted_participants = deleted_participants_admin_new (gv->config.prune_deleted_ppant.delay); gv->deleted_participants = deleted_participants_admin_new (&gv->logconfig, gv->config.prune_deleted_ppant.delay);
gv->guid_hash = ephash_new (gv); gv->guid_hash = ephash_new (gv);
ddsrt_mutex_init (&gv->privileged_pp_lock); ddsrt_mutex_init (&gv->privileged_pp_lock);