Skip to content

Commit

Permalink
Style & structure fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianpick committed Jan 8, 2024
1 parent 8c6da24 commit 5ccf8e2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/core/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ typedef union QUIC_STREAM_FLAGS {
BOOLEAN LocalCloseReset : 1; // Locally closed (locally aborted).
BOOLEAN LocalCloseResetReliable : 1; // Indicates that we should shutdown the send path once we sent/ACK'd ReliableOffsetSend bytes.
BOOLEAN LocalCloseResetReliableAcked : 1; // Indicates the peer has acknowledged we will stop sending once we sent/ACK'd ReliableOffsetSend bytes.
BOOLEAN RemoteCloseResetReliable : 1; // Indicates that the peer initiaited a reliable reset. Keep Recv path available for RecvMaxLength bytes.
BOOLEAN RemoteCloseResetReliable : 1; // Indicates that the peer initiated a reliable reset. Keep Recv path available for RecvMaxLength bytes.
BOOLEAN ReceivedStopSending : 1; // Peer sent STOP_SENDING frame.
BOOLEAN LocalCloseAcked : 1; // Any close acknowledged.
BOOLEAN FinAcked : 1; // Our FIN was acknowledged.
Expand All @@ -144,6 +144,8 @@ typedef union QUIC_STREAM_FLAGS {
BOOLEAN ReceiveCallPending : 1; // There is an uncompleted receive to the app.
BOOLEAN ReceiveCallActive : 1; // There is an active receive to the app.
BOOLEAN SendDelayed : 1; // A delayed send is currently queued.
BOOLEAN CancelOnLoss : 1; // Indicates that the stream is to be canceled
// if loss is detected.

BOOLEAN HandleSendShutdown : 1; // Send shutdown complete callback delivered.
BOOLEAN HandleShutdown : 1; // Shutdown callback delivered.
Expand All @@ -155,8 +157,6 @@ typedef union QUIC_STREAM_FLAGS {

BOOLEAN InStreamTable : 1; // The stream is currently in the connection's table.
BOOLEAN DelayIdFcUpdate : 1; // Delay stream ID FC updates to StreamClose.

BOOLEAN CancelOnLoss : 1; // Indicates that the stream is to be canceled if loss is detected.
};
} QUIC_STREAM_FLAGS;

Expand Down
15 changes: 9 additions & 6 deletions src/core/stream_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,10 @@ QuicStreamSendFlush(

CXPLAT_DBG_ASSERT(!(SendRequest->Flags & QUIC_SEND_FLAG_BUFFERED));

//
// If a send has the 'cancel on loss' flag set, we irreversibly switch
// the associated stream over to that behavior.
//
if (!Stream->Flags.CancelOnLoss &&
(SendRequest->Flags & QUIC_SEND_FLAG_CANCEL_ON_LOSS) != 0) {
Stream->Flags.CancelOnLoss = TRUE;
Expand Down Expand Up @@ -1371,25 +1373,26 @@ QuicStreamOnLoss(
Done:

if (AddSendFlags != 0) {

// Check stream's 'cancel on loss' flag to determine how to handle the resends queued up at this point.
//
// Check stream's 'cancel on loss' flag to determine how to handle
// the resends queued up at this point.
//
if (Stream->Flags.CancelOnLoss) {
QUIC_STREAM_EVENT Event;
Event.Type = QUIC_STREAM_EVENT_CANCEL_ON_LOSS;
Event.CANCEL_ON_LOSS.ErrorCode = 0;

// Call to app callback requesting error code.
(void)QuicStreamIndicateEvent(Stream, &Event);

//
// Immediately terminate stream (in both directions, if open)
// giving the error code from the app.
//
QuicStreamShutdown(
Stream,
QUIC_STREAM_SHUTDOWN_FLAG_ABORT,
Event.CANCEL_ON_LOSS.ErrorCode);

// Don't resend any data.
return FALSE;
return FALSE; // Don't resend any data.
}

if (!Stream->Flags.InRecovery) {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/dbg/quictypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ typedef union QUIC_STREAM_FLAGS {
BOOLEAN ReceiveCallPending : 1; // There is an uncompleted receive to the app.
BOOLEAN ReceiveCallActive : 1; // There is an active receive to the app.
BOOLEAN SendDelayed : 1; // A delayed send is currently queued.
BOOLEAN CancelOnLoss : 1; // Indicates that the stream is to be canceled
// if loss is detected.

BOOLEAN HandleSendShutdown : 1; // Send shutdown complete callback delivered.
BOOLEAN HandleShutdown : 1; // Shutdown callback delivered.
Expand Down
4 changes: 2 additions & 2 deletions src/test/MsQuicTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ QuicAbortiveTransfers(
void
QuicCancelOnLossSend(
_In_ bool DropPackets
);
);

void
QuicTestCidUpdate(
Expand Down Expand Up @@ -1262,6 +1262,6 @@ typedef struct {

#define IOCTL_QUIC_RUN_CANCEL_ON_LOSS \
QUIC_CTL_CODE(118, METHOD_BUFFERED, FILE_WRITE_DATA)
// QUIC_RUN_CANCEL_ON_LOSS_PARAMS
// QUIC_RUN_CANCEL_ON_LOSS_PARAMS

#define QUIC_MAX_IOCTL_FUNC_CODE 118
6 changes: 6 additions & 0 deletions src/test/bin/quic_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,7 @@ TEST_P(WithAbortiveArgs, AbortiveShutdown) {
}
}

#if QUIC_TEST_DATAPATH_HOOKS_ENABLED
TEST_P(WithCancelOnLossArgs, CancelOnLossSend) {
TestLoggerT<ParamType> Logger("QuicCancelOnLossSend", GetParam());
if (TestingKernelMode) {
Expand All @@ -1978,6 +1979,7 @@ TEST_P(WithCancelOnLossArgs, CancelOnLossSend) {
QuicCancelOnLossSend(GetParam().DropPackets);
}
}
#endif

TEST_P(WithCidUpdateArgs, CidUpdate) {
TestLoggerT<ParamType> Logger("QuicTestCidUpdate", GetParam());
Expand Down Expand Up @@ -2443,11 +2445,15 @@ INSTANTIATE_TEST_SUITE_P(
WithAbortiveArgs,
testing::ValuesIn(AbortiveArgs::Generate()));

#if QUIC_TEST_DATAPATH_HOOKS_ENABLED

INSTANTIATE_TEST_SUITE_P(
Misc,
WithCancelOnLossArgs,
testing::ValuesIn(CancelOnLossArgs::Generate()));

#endif

INSTANTIATE_TEST_SUITE_P(
Misc,
WithCidUpdateArgs,
Expand Down
4 changes: 1 addition & 3 deletions src/test/bin/winkernel/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,7 @@ QuicTestCtlEvtIoDeviceControl(

case IOCTL_QUIC_RUN_CANCEL_ON_LOSS:
CXPLAT_FRE_ASSERT(Params != nullptr);
QuicTestCtlRun(
QuicCancelOnLossSend(
Params->DropPackets));
QuicTestCtlRun(QuicCancelOnLossSend(Params->DropPackets));
break;

default:
Expand Down
18 changes: 7 additions & 11 deletions src/test/lib/DataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ QuicCancelOnLossStreamHandler(
_In_ struct MsQuicStream* /* Stream */,
_In_opt_ void* Context,
_Inout_ QUIC_STREAM_EVENT* Event
)
)
{
if (Context == nullptr) {
return QUIC_STATUS_INVALID_PARAMETER;
Expand All @@ -1426,8 +1426,7 @@ QuicCancelOnLossStreamHandler(
if (TestContext->IsServer) { // server-side 'cancel on loss' detection
TestContext->SendPhaseEndedEvent.Set();
TestContext->ExitCode = Event->PEER_SEND_ABORTED.ErrorCode;
}
else {
} else {
Status = QUIC_STATUS_INVALID_STATE;
}
break;
Expand All @@ -1441,17 +1440,15 @@ QuicCancelOnLossStreamHandler(
if (!TestContext->IsDropScenario) { // if drop scenario, we use 'cancel on loss' event
TestContext->SendPhaseEndedEvent.Set();
}
}
else {
} else {
Status = QUIC_STATUS_INVALID_STATE;
}
break;
case QUIC_STREAM_EVENT_CANCEL_ON_LOSS:
if (!TestContext->IsServer && TestContext->IsDropScenario) { // only client sends & only happens if in drop scenario
Event->CANCEL_ON_LOSS.ErrorCode = CancelOnLossContext::ErrorExitCode;
TestContext->SendPhaseEndedEvent.Set();
}
else {
} else {
Status = QUIC_STATUS_INVALID_STATE;
}
break;
Expand All @@ -1468,7 +1465,7 @@ QuicCancelOnLossConnectionHandler(
_In_ struct MsQuicConnection* /* Connection */,
_In_opt_ void* Context,
_Inout_ QUIC_CONNECTION_EVENT* Event
)
)
{
if (Context == nullptr) {
return QUIC_STATUS_INVALID_PARAMETER;
Expand Down Expand Up @@ -1532,7 +1529,7 @@ QuicCancelOnLossListenerHandler(
void
QuicCancelOnLossSend(
_In_ bool DropPackets
)
)
{
MsQuicRegistration Registration;
TEST_TRUE(Registration.IsValid());
Expand Down Expand Up @@ -1640,8 +1637,7 @@ QuicCancelOnLossSend(
// Check results.
if (DropPackets) {
TEST_EQUAL(ServerContext.ExitCode, CancelOnLossContext::ErrorExitCode);
}
else {
} else {
TEST_EQUAL(ServerContext.ExitCode, CancelOnLossContext::SuccessExitCode);
}
}
Expand Down

0 comments on commit 5ccf8e2

Please sign in to comment.