Skip to content

Commit

Permalink
restore state whenever handling of NCID fails
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuho committed Dec 23, 2024
1 parent cf2e0a5 commit c0451b0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/remote_cid.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,11 @@ int quicly_remote_cid_register(quicly_remote_cid_set_t *set, uint64_t sequence,
assert(sequence >= retire_prior_to);

/* First, handle retire_prior_to. This order is important as it is possible to receive a NEW_CONNECTION_ID frame such that it
* retires active_connection_id_limit CIDs and then installs one new CID. */
if ((ret = unregister_prior_to(set, retire_prior_to)) != 0)
return ret;

/* Then, register given value. If an error occurs, restore the backup and send the error. */
if ((ret = do_register(set, sequence, cid, cid_len, srt)) != 0) {
* retires active_connection_id_limit CIDs and then installs one new CID. Then, the new CID is registered. If either of the two
* fails, the state is restored to the original so that we can send an error to the peer. */
if ((ret = unregister_prior_to(set, retire_prior_to)) != 0 ||
(ret = do_register(set, sequence, cid, cid_len, srt)) != 0)
*set = backup;
return ret;
}

return ret;
}
Expand Down

0 comments on commit c0451b0

Please sign in to comment.