@@ -161,10 +161,6 @@ static void mca_btl_uct_tl_destructor(mca_btl_uct_tl_t *tl)
161161 ucs_async_context_destroy (tl -> ucs_async );
162162 }
163163
164- if (tl -> uct_md ) {
165- OBJ_RELEASE (tl -> uct_md );
166- }
167-
168164 free (tl -> uct_tl_name );
169165 free (tl -> uct_dev_name );
170166
@@ -436,7 +432,6 @@ static mca_btl_uct_tl_t *mca_btl_uct_create_tl(mca_btl_uct_module_t *module, mca
436432
437433 /* initialize btl tl structure */
438434 tl -> uct_md = md ;
439- OBJ_RETAIN (md );
440435
441436 tl -> uct_tl_name = strdup (tl_desc -> tl_name );
442437 tl -> uct_dev_name = strdup (tl_desc -> dev_name );
@@ -457,7 +452,7 @@ static mca_btl_uct_tl_t *mca_btl_uct_create_tl(mca_btl_uct_module_t *module, mca
457452 return NULL ;
458453 }
459454
460- BTL_VERBOSE (("Interface CAPS for tl %s::%s: 0x%lx" , module -> md -> md_name , tl_desc -> tl_name ,
455+ BTL_VERBOSE (("Interface CAPS for tl %s::%s: 0x%lx" , md -> md_name , tl_desc -> tl_name ,
461456 (unsigned long ) tl -> uct_iface_attr .cap .flags ));
462457
463458 return tl ;
@@ -489,7 +484,6 @@ static void mca_btl_uct_set_tl_rdma(mca_btl_uct_module_t *module, mca_btl_uct_tl
489484 .cap .put .max_bcopy ;
490485
491486 module -> rdma_tl = tl ;
492- OBJ_RETAIN (tl );
493487
494488 tl -> tl_index = (module -> am_tl && tl != module -> am_tl ) ? 1 : 0 ;
495489 module -> comm_tls [tl -> tl_index ] = tl ;
@@ -502,7 +496,6 @@ static void mca_btl_uct_set_tl_am(mca_btl_uct_module_t *module, mca_btl_uct_tl_t
502496{
503497 BTL_VERBOSE (("tl %s is suitable for active-messaging" , tl -> uct_tl_name ));
504498 module -> am_tl = tl ;
505- OBJ_RETAIN (tl );
506499
507500 tl -> tl_index = (module -> rdma_tl && tl != module -> rdma_tl ) ? 1 : 0 ;
508501 module -> comm_tls [tl -> tl_index ] = tl ;
@@ -532,8 +525,6 @@ static int mca_btl_uct_set_tl_conn(mca_btl_uct_module_t *module, mca_btl_uct_tl_
532525 return rc ;
533526 }
534527
535- OBJ_RETAIN (tl );
536-
537528 if (!tl -> max_device_contexts ) {
538529 /* if a tl is only being used to create connections do not bother with multiple
539530 * contexts */
@@ -591,9 +582,6 @@ int mca_btl_uct_query_tls(mca_btl_uct_module_t *module, mca_btl_uct_md_t *md,
591582 bool evaluate_for_conn_only )
592583{
593584 mca_btl_uct_tl_t * tl ;
594- opal_list_t tl_list ;
595-
596- OBJ_CONSTRUCT (& tl_list , opal_list_t );
597585
598586 for (unsigned i = 0 ; i < tl_count ; ++ i ) {
599587 int priority = 0 ;
@@ -623,28 +611,27 @@ int mca_btl_uct_query_tls(mca_btl_uct_module_t *module, mca_btl_uct_md_t *md,
623611 if (mca_btl_uct_tl_supports_conn (tl ) && evaluate_for_conn_only ) {
624612 BTL_VERBOSE (("evaluating tl %s for forming connections" , tl_descs [i ].tl_name ));
625613 int rc = mca_btl_uct_set_tl_conn (module , tl );
626- OBJ_RELEASE (tl );
627614
628615 if (OPAL_SUCCESS == rc ) {
616+ opal_list_append (& md -> tls , & tl -> super );
629617 return OPAL_SUCCESS ;
630618 }
631619
632620 BTL_VERBOSE (("tl %s cannot be used for forming connections" , tl_descs [i ].tl_name ));
633621 } else {
634- opal_list_append (& tl_list , & tl -> super );
622+ opal_list_append (& md -> tls , & tl -> super );
635623 }
636624 }
637625 }
638626
639- if (0 == opal_list_get_size (& tl_list )) {
627+ if (0 == opal_list_get_size (& md -> tls )) {
640628 BTL_VERBOSE (("no suitable tls match filter: %s" , mca_btl_uct_component .allowed_transports ));
641- OBJ_DESTRUCT (& tl_list );
642629 return OPAL_ERR_NOT_AVAILABLE ;
643630 }
644631
645- opal_list_sort (& tl_list , tl_compare );
632+ opal_list_sort (& md -> tls , tl_compare );
646633
647- OPAL_LIST_FOREACH (tl , & tl_list , mca_btl_uct_tl_t ) {
634+ OPAL_LIST_FOREACH (tl , & md -> tls , mca_btl_uct_tl_t ) {
648635 mca_btl_uct_evaluate_tl (module , tl );
649636 if (NULL != module -> am_tl && NULL != module -> rdma_tl
650637 && (NULL != module -> conn_tl
@@ -676,15 +663,21 @@ int mca_btl_uct_query_tls(mca_btl_uct_module_t *module, mca_btl_uct_md_t *md,
676663 module -> super .btl_free = NULL ;
677664 }
678665
679- OPAL_LIST_DESTRUCT (& tl_list );
680-
681666 if (!(NULL != module -> am_tl && mca_btl_uct_tl_requires_connection_tl (module -> am_tl ))
682667 && !(NULL != module -> rdma_tl && mca_btl_uct_tl_requires_connection_tl (module -> rdma_tl ))
683668 && module -> conn_tl ) {
684669 /* no connection tl needed for selected transports */
685- OBJ_RELEASE (module -> conn_tl );
686670 module -> conn_tl = NULL ;
687671 }
688672
673+ /* clear out unused tls */
674+ mca_btl_uct_tl_t * next ;
675+ OPAL_LIST_FOREACH_SAFE (tl , next , & md -> tls , mca_btl_uct_tl_t ) {
676+ if (tl != module -> conn_tl && tl != module -> rdma_tl && tl != module -> am_tl ) {
677+ opal_list_remove_item (& md -> tls , & tl -> super );
678+ OBJ_RELEASE (tl );
679+ }
680+ }
681+
689682 return OPAL_SUCCESS ;
690683}
0 commit comments