Skip to content

Commit

Permalink
Spinquic to use operation priority
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-GS committed Aug 2, 2024
1 parent 3c63ba5 commit e0d1afa
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/tools/spin/spinquic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ struct SetParamHelper {
void SetUint64(uint32_t _Type, uint64_t Value) {
Type = _Type; Param.u64 = Value; Size = sizeof(Value);
}
void SetPriority() {
Type |= QUIC_PARAM_HIGH_PRIORITY;
}
void Apply(HQUIC Handle) {
if (Type != -1) {
MsQuic.SetParam(Handle, Type, Size, IsPtr ? Param.ptr : &Param);
Expand Down Expand Up @@ -828,6 +831,10 @@ void SpinQuicSetRandomConnectionParam(HQUIC Connection, uint16_t ThreadID)
break;
}

if (GetRandom(2)) {
Helper.SetPriority();
}

Helper.Apply(Connection);
}

Expand All @@ -853,6 +860,10 @@ void SpinQuicSetRandomStreamParam(HQUIC Stream, uint16_t ThreadID)
break;
}

if (GetRandom(2)) {
Helper.SetPriority();
}

Helper.Apply(Stream);
}

Expand Down Expand Up @@ -881,6 +892,10 @@ void SpinQuicGetRandomParam(HQUIC Handle, uint16_t ThreadID)
uint32_t Combined = ((Level+1) << 28) + Param;
Combined &= ~QUIC_PARAM_HIGH_PRIORITY; // TODO: enable high priority GetParam

if (GetRandom(2)) {
Combined |= QUIC_PARAM_HIGH_PRIORITY;
}

uint8_t OutBuffer[200];
uint32_t OutBufferLength = (uint32_t)GetRandom(sizeof(OutBuffer) + 1);

Expand Down Expand Up @@ -1010,7 +1025,7 @@ void Spin(Gbs& Gb, LockableVector<HQUIC>& Connections, std::vector<HQUIC>* Liste
Buffer->Buffer = Gb.SendBuffer + StreamCtx->SendOffset;
Buffer->Length = Length;
if (QUIC_SUCCEEDED(
MsQuic.StreamSend(Stream, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(16), Buffer))) {
MsQuic.StreamSend(Stream, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(128), Buffer))) {
StreamCtx->SendOffset = (uint8_t)(StreamCtx->SendOffset + Length);
} else {
delete Buffer;
Expand Down Expand Up @@ -1145,7 +1160,7 @@ void Spin(Gbs& Gb, LockableVector<HQUIC>& Connections, std::vector<HQUIC>* Liste
if (Buffer) {
Buffer->Buffer = Gb.SendBuffer;
Buffer->Length = MaxBufferSizes[GetRandom(BufferCount)];
if (QUIC_FAILED(MsQuic.DatagramSend(Connection, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(8), Buffer))) {
if (QUIC_FAILED(MsQuic.DatagramSend(Connection, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(128), Buffer))) {
delete Buffer;
}
}
Expand Down

0 comments on commit e0d1afa

Please sign in to comment.