Skip to content

Commit

Permalink
Retry Force CID Update on Failure in Test Code (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Feb 24, 2020
1 parent 95f3a38 commit 2aacc7f
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/test/lib/TestConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,30 @@ TestConnection::ForceKeyUpdate()
QUIC_STATUS
TestConnection::ForceCidUpdate()
{
return
MsQuic->SetParam(
QuicConnection,
QUIC_PARAM_LEVEL_CONNECTION,
QUIC_PARAM_CONN_FORCE_CID_UPDATE,
0,
nullptr);
QUIC_STATUS Status;
uint32_t Try = 0;

do {
//
// Forcing a CID update is only allowed when the handshake is confirmed.
// So, even if the caller waits for connection complete, it's possible
// the call can fail with QUIC_STATUS_INVALID_STATE. To get around this
// we allow for a couple retries (with some sleeps).
//
if (Try != 0) {
QuicSleep(100);
}
Status =
MsQuic->SetParam(
QuicConnection,
QUIC_PARAM_LEVEL_CONNECTION,
QUIC_PARAM_CONN_FORCE_CID_UPDATE,
0,
nullptr);

} while (Status == QUIC_STATUS_INVALID_STATE && ++Try <= 3);

return Status;
}

QUIC_STATUS
Expand Down

0 comments on commit 2aacc7f

Please sign in to comment.