Skip to content

Commit

Permalink
Add global internal param to get default datapath worker pool (#4535)
Browse files Browse the repository at this point in the history
* Add global internal param to get default datapath worker pool

* Review comments

* Only run test in debug

* Fix test
  • Loading branch information
ThadHouse committed Sep 8, 2024
1 parent e5aa857 commit fb96220
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,24 @@ QuicLibraryGetGlobalParam(
Status = QUIC_STATUS_SUCCESS;
break;

case QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL:

if (*BufferLength != sizeof(CXPLAT_WORKER_POOL*)) {
*BufferLength = sizeof(CXPLAT_WORKER_POOL*);
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
break;
}

if (Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}

*(CXPLAT_WORKER_POOL**)Buffer = &MsQuicLib.WorkerPool;

Status = QUIC_STATUS_SUCCESS;
break;

default:
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
Expand Down
1 change: 1 addition & 0 deletions src/inc/msquicp.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ typedef struct QUIC_PRIVATE_TRANSPORT_PARAMETER {
#endif
#define QUIC_PARAM_GLOBAL_IN_USE 0x81000004 // BOOLEAN
#define QUIC_PARAM_GLOBAL_DATAPATH_FEATURES 0x81000005 // uint32_t
#define QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL 0x81000006 // CXPLAT_WORKER_POOL*

//
// The different private parameters for Configuration.
Expand Down
46 changes: 46 additions & 0 deletions src/test/lib/ApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2681,6 +2681,52 @@ void QuicTestGlobalParam()
}
}

#if DEBUG
//
// QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL
//
{
TestScopeLogger LogScope0("QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL");
{
TestScopeLogger LogScope1("SetParam");
//
// Invalid features
//
{
TestScopeLogger LogScope2("SetParam is not allowed");
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_PARAMETER,
MsQuic->SetParam(
nullptr,
QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL,
0,
nullptr));
}
}

{
TestScopeLogger LogScope2("GetParam. Failed by missing MsQuicLib.WorkerPool");
uint32_t Length = 0;
TEST_QUIC_STATUS(
QUIC_STATUS_BUFFER_TOO_SMALL,
MsQuic->GetParam(
nullptr,
QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL,
&Length,
nullptr));
TEST_EQUAL(Length, sizeof(CXPLAT_WORKER_POOL*));

CXPLAT_WORKER_POOL* WorkerPool = 0;
TEST_QUIC_SUCCEEDED(
MsQuic->GetParam(
nullptr,
QUIC_PARAM_GLOBAL_PLATFORM_WORKER_POOL,
&Length,
&WorkerPool));
}
}
#endif

//
// Invalid parameter
//
Expand Down

0 comments on commit fb96220

Please sign in to comment.