@@ -616,20 +616,20 @@ static pj_status_t create_conf_port( pj_pool_t *parent_pool,
616616#else
617617 pool = pj_pool_create (parent_pool -> factory , pname , 500 , 500 , NULL );
618618#endif
619- if (!pool ) {
620- status = PJ_ENOMEM ;
621- goto on_return ;
622- }
619+ if (!pool )
620+ return PJ_ENOMEM ;
623621
624622 /* Create port. */
625623 conf_port = PJ_POOL_ZALLOC_T (pool , struct conf_port );
626- PJ_ASSERT_ON_FAIL (conf_port , {status = PJ_ENOMEM ; goto on_return ;});
624+ PJ_ASSERT_ON_FAIL (conf_port , {pj_pool_release ( pool ); return PJ_ENOMEM ;});
627625 conf_port -> pool = pool ;
628626
629627 /* Increment port ref count to avoid premature destroy due to
630628 * asynchronous port removal.
631629 */
632630 if (port ) {
631+ conf_port -> port = port ;
632+
633633 if (!port -> grp_lock ) {
634634 /* Create group lock if it does not have one */
635635 pjmedia_port_init_grp_lock (port , pool , NULL );
@@ -845,27 +845,11 @@ static pj_status_t create_conf_port( pj_pool_t *parent_pool,
845845
846846on_return :
847847 if (status != PJ_SUCCESS ) {
848- if (conf_port ) {
849- /* Destroy resample if this conf port has it. */
850- if (conf_port -> rx_resample )
851- pjmedia_resample_destroy (conf_port -> rx_resample );
852-
853- if (conf_port -> tx_resample )
854- pjmedia_resample_destroy (conf_port -> tx_resample );
855-
856- if (conf_port -> tx_lock )
857- CONF_CHECK_SUCCESS (pj_lock_destroy (conf_port -> tx_lock ),(void )0 );
858- if (conf_port -> free_node_cache )
859- CONF_CHECK_SUCCESS (pj_atomic_slist_destroy (conf_port -> free_node_cache ),(void )0 );
860- if (conf_port -> buff_to_mix )
861- CONF_CHECK_SUCCESS (pj_atomic_slist_destroy (conf_port -> buff_to_mix ),(void )0 );
862- if (conf_port -> requests_to_mix )
863- CONF_CHECK_SUCCESS (pj_atomic_destroy (conf_port -> requests_to_mix ),(void )0 );
864-
865- //TODO grp_lock ?
866- }
867- if (pool )
868- pj_pool_release (pool );
848+ /* Decrease conf port ref count */
849+ if (conf_port -> port && conf_port -> port -> grp_lock )
850+ pj_grp_lock_dec_ref (conf_port -> port -> grp_lock );
851+ else
852+ destroy_conf_port (conf_port );
869853 }
870854
871855 return status ;
@@ -2478,6 +2462,13 @@ static void destroy_conf_port( struct conf_port *conf_port )
24782462 if (conf_port -> tx_lock != NULL )
24792463 pj_lock_destroy (conf_port -> tx_lock );
24802464
2465+ if (conf_port -> free_node_cache )
2466+ pj_atomic_slist_destroy (conf_port -> free_node_cache );
2467+ if (conf_port -> buff_to_mix )
2468+ pj_atomic_slist_destroy (conf_port -> buff_to_mix );
2469+ if (conf_port -> requests_to_mix )
2470+ pj_atomic_destroy (conf_port -> requests_to_mix );
2471+
24812472 pj_pool_safe_release (& conf_port -> pool );
24822473}
24832474
0 commit comments