Skip to content

Commit

Permalink
SpinQuic: Pend some receives and try resuming them. (microsoft#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
anrossi authored May 18, 2021
1 parent 3163953 commit 7977dda
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/tools/spin/spinquic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef enum {
SpinQuicAPICallGetParamConnection,
SpinQuicAPICallGetParamStream,
SpinQuicAPICallDatagramSend,
SpinQuicAPICallReceiveSetEnabled,
SpinQuicAPICallCount // Always the last element
} SpinQuicAPICall;

Expand Down Expand Up @@ -200,6 +201,11 @@ QUIC_STATUS QUIC_API SpinQuicHandleStreamEvent(HQUIC Stream, void * /* Context *
case QUIC_STREAM_EVENT_PEER_SEND_SHUTDOWN:
MsQuic->StreamShutdown(Stream, (QUIC_STREAM_SHUTDOWN_FLAGS)GetRandom(16), 0);
break;
case QUIC_STREAM_EVENT_RECEIVE:
if (GetRandom(5) == 0) {
return QUIC_STATUS_PENDING;
}
break;
default:
break;
}
Expand Down Expand Up @@ -519,6 +525,18 @@ void Spin(LockableVector<HQUIC>& Connections, std::vector<HQUIC>* Listeners = nu
}
break;
}
case SpinQuicAPICallReceiveSetEnabled: {
auto Connection = Connections.TryGetRandom();
BAIL_ON_NULL_CONNECTION(Connection);
auto ctx = SpinQuicConnection::Get(Connection);
{
std::lock_guard<std::mutex> Lock(ctx->Lock);
auto Stream = ctx->TryGetStream();
if (Stream == nullptr) continue;
MsQuic->StreamReceiveSetEnabled(Stream, GetRandom(2) == 0);
}
break;
}
case SpinQuicAPICallStreamShutdown: {
auto Connection = Connections.TryGetRandom();
BAIL_ON_NULL_CONNECTION(Connection);
Expand Down

0 comments on commit 7977dda

Please sign in to comment.