diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h index 664a120e7b65240df49ca497e21f5e275b965eb4..c994ab538110ac4b40f3ed3f3620c04e2166da24 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h @@ -755,6 +755,7 @@ void picoquic_register_path(picoquic_cnx_t* cnx, picoquic_path_t * path_x); void picoquic_delete_path(picoquic_cnx_t* cnx, int path_index); void picoquic_demote_path(picoquic_cnx_t* cnx, int path_index, uint64_t current_time); void picoquic_promote_path_to_default(picoquic_cnx_t* cnx, int path_index, uint64_t current_time); +int picoquic_count_remote_connection_id_ref(picoquic_cnx_t* cnx, picoquic_connection_id_t * cid); void picoquic_delete_abandoned_paths(picoquic_cnx_t* cnx, uint64_t current_time, uint64_t * next_wake_time); /* Management of the CNX-ID stash */ diff --git a/picoquic/quicctx.c b/picoquic/quicctx.c index 3bd56eb1099760b93950692fe37bf986fd12dbf2..6e1ac741b31e2dfab870b679d4ad8e70cc346c37 100644 --- a/picoquic/quicctx.c +++ b/picoquic/quicctx.c @@ -860,6 +860,26 @@ void picoquic_delete_path(picoquic_cnx_t* cnx, int path_index) cnx->path[cnx->nb_paths] = NULL; } +/* + * Connection ID may be used on more than one path. + * Provide a count of how many such values we see. + */ + +int picoquic_count_remote_connection_id_ref(picoquic_cnx_t* cnx, picoquic_connection_id_t * cid) +{ + int count = 0; + int path_index_current = 0; + + while (path_index_current < cnx->nb_paths) { + if (picoquic_compare_connection_id(cid, &cnx->path[path_index_current]->remote_cnxid) == 0) { + count++; + } + path_index_current++; + } + + return count; +} + /* * Path challenges may be abandoned if they are tried too many times without success. */ @@ -896,7 +916,8 @@ void picoquic_delete_abandoned_paths(picoquic_cnx_t* cnx, uint64_t current_time, while (cnx->nb_paths > path_index_good) { int d_path = cnx->nb_paths - 1; - if (!picoquic_is_connection_id_null(cnx->path[d_path]->remote_cnxid)) { + if (!picoquic_is_connection_id_null(cnx->path[d_path]->remote_cnxid) && + picoquic_count_remote_connection_id_ref(cnx, &cnx->path[d_path]->remote_cnxid) == 1) { (void)picoquic_queue_retire_connection_id_frame(cnx, cnx->path[d_path]->remote_cnxid_sequence); } picoquic_delete_path(cnx, d_path);