Stop threads doing handshake processing earlier

In particular before the state they depend on gets torn down.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-03-26 20:21:56 +01:00 committed by eboasson
parent fa0c6777d4
commit c8d8d2f8e6
5 changed files with 38 additions and 26 deletions

View file

@ -168,6 +168,13 @@ struct ddsi_handshake * ddsi_handshake_find(struct participant *pp, struct proxy
*/
void ddsi_handshake_admin_init(struct ddsi_domaingv *gv);
/**
* @brief Stop handshake background processing.
*
* @param[in] gv The global parameters
*/
void ddsi_handshake_admin_stop(struct ddsi_domaingv *gv);
/**
* @brief Deinitialze the handshake administration.
*

View file

@ -1102,6 +1102,8 @@ dds_return_t q_omg_security_load( struct dds_security_context *security_context,
void q_omg_security_init( struct ddsi_domaingv *gv );
void q_omg_security_stop (struct ddsi_domaingv *gv);
void q_omg_security_deinit( struct ddsi_domaingv *gv );
bool q_omg_is_security_loaded( struct dds_security_context *sc );
@ -1395,10 +1397,6 @@ inline dds_return_t q_omg_security_load( UNUSED_ARG( struct dds_security_context
return DDS_RETCODE_ERROR;
}
inline void q_omg_security_init( UNUSED_ARG( struct dds_security_context *sc) ) {}
inline void q_omg_security_deinit( UNUSED_ARG( struct dds_security_context *sc) ) {}
inline bool q_omg_is_security_loaded( UNUSED_ARG( struct dds_security_context *sc )) { return false; }
inline void q_omg_security_deregister_remote_reader_match(UNUSED_ARG(const struct proxy_reader *prd), UNUSED_ARG(const struct writer *wr), UNUSED_ARG(struct wr_prd_match *match))

View file

@ -1120,21 +1120,6 @@ static void release_handshake(void *arg)
ddsi_handshake_release((struct ddsi_handshake *)arg);
}
static void ddsi_handshake_admin_delete(struct ddsi_hsadmin *hsadmin)
{
if (hsadmin)
{
ddsrt_mutex_destroy(&hsadmin->lock);
ddsrt_avl_free(&handshake_treedef, &hsadmin->handshakes, release_handshake);
if (hsadmin->fsm_control)
{
dds_security_fsm_control_stop(hsadmin->fsm_control);
dds_security_fsm_control_free(hsadmin->fsm_control);
}
ddsrt_free(hsadmin);
}
}
static struct ddsi_handshake * ddsi_handshake_find_locked(
struct ddsi_hsadmin *hsadmin,
struct participant *pp,
@ -1213,10 +1198,23 @@ void ddsi_handshake_admin_init(struct ddsi_domaingv *gv)
void ddsi_handshake_admin_deinit(struct ddsi_domaingv *gv)
{
assert(gv);
ddsi_handshake_admin_delete(gv->hsadmin);
struct ddsi_hsadmin *hsadmin = gv->hsadmin;
if (hsadmin)
{
ddsrt_mutex_destroy(&hsadmin->lock);
ddsrt_avl_free(&handshake_treedef, &hsadmin->handshakes, release_handshake);
if (hsadmin->fsm_control)
dds_security_fsm_control_free(hsadmin->fsm_control);
ddsrt_free(hsadmin);
}
}
void ddsi_handshake_admin_stop(struct ddsi_domaingv *gv)
{
struct ddsi_hsadmin *hsadmin = gv->hsadmin;
if (hsadmin && hsadmin->fsm_control)
dds_security_fsm_control_stop(hsadmin->fsm_control);
}
#else

View file

@ -623,6 +623,11 @@ static void release_plugins (dds_security_context *sc)
sc->crypto_context = NULL;
}
void q_omg_security_stop (struct ddsi_domaingv *gv)
{
ddsi_handshake_admin_stop(gv);
}
void q_omg_security_deinit (struct ddsi_domaingv *gv)
{
dds_security_context *sc = gv->security_context;

View file

@ -1518,12 +1518,12 @@ err_unicast_sockets:
ddsrt_hh_free (gv->sertopics);
ddsrt_mutex_destroy (&gv->sertopics_lock);
#ifdef DDSI_INCLUDE_SECURITY
q_omg_security_stop (gv); // should be a no-op as it starts lazily
q_omg_security_deinit (gv);
ddsi_xqos_fini (&gv->builtin_stateless_xqos_wr);
ddsi_xqos_fini (&gv->builtin_stateless_xqos_rd);
ddsi_xqos_fini (&gv->builtin_volatile_xqos_wr);
ddsi_xqos_fini (&gv->builtin_volatile_xqos_rd);
q_omg_security_deinit (gv);
#endif
ddsi_xqos_fini (&gv->builtin_endpoint_xqos_wr);
ddsi_xqos_fini (&gv->builtin_endpoint_xqos_rd);
@ -1749,6 +1749,12 @@ void rtps_stop (struct ddsi_domaingv *gv)
thread_state_asleep (ts1);
}
/* Stop background (handshake) processing in security implementation,
do this only once we know no new events will be coming in. */
#if DDSI_INCLUDE_SECURITY
q_omg_security_stop (gv);
#endif
/* Wait until all participants are really gone => by then we can be
certain that no new GC requests will be added, short of what we
do here */
@ -1854,7 +1860,6 @@ void rtps_fini (struct ddsi_domaingv *gv)
}
ddsi_tkmap_free (gv->m_tkmap);
entity_index_free (gv->entity_index);
gv->entity_index = NULL;
deleted_participants_admin_free (gv->deleted_participants);
@ -1873,12 +1878,11 @@ void rtps_fini (struct ddsi_domaingv *gv)
ddsrt_mutex_destroy (&gv->sertopics_lock);
#ifdef DDSI_INCLUDE_SECURITY
q_omg_security_deinit (gv);
ddsi_xqos_fini (&gv->builtin_stateless_xqos_wr);
ddsi_xqos_fini (&gv->builtin_stateless_xqos_rd);
ddsi_xqos_fini (&gv->builtin_volatile_xqos_wr);
ddsi_xqos_fini (&gv->builtin_volatile_xqos_rd);
q_omg_security_deinit (gv);
#endif
ddsi_xqos_fini (&gv->builtin_endpoint_xqos_wr);
ddsi_xqos_fini (&gv->builtin_endpoint_xqos_rd);