From b3f71e93f2571de4de79263fafbf7c81e53bfbd0 Mon Sep 17 00:00:00 2001 From: ami-GS <1991.daiki@gmail.com> Date: Fri, 6 Oct 2023 12:16:15 -0700 Subject: [PATCH] use recv complete --- scripts/TcpTests.json | 19 +++++++++++ src/platform/datapath_epoll.c | 60 ++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 18 deletions(-) diff --git a/scripts/TcpTests.json b/scripts/TcpTests.json index 886fe4a1c2..527c4ce7d0 100644 --- a/scripts/TcpTests.json +++ b/scripts/TcpTests.json @@ -22,6 +22,25 @@ "ResultsMatcher": ".*@ (.*) kbps.*", "Formats": ["{0} kbps"], "RegressionThreshold": "-8.0" + }, + { + "TestName": "TcpThroughputUp", + "Local" : { + "Platform": "linux", + "Tls": ["openssl", "openssl3"], + "Arch": ["x64", "arm"], + "Exe": "secnetperf", + "Arguments": "-test:Throughput -target:$RemoteAddress -bind:$LocalAddress:4434 -ip:4 -uni:1 -upload:2000000000 -tcp:1" + }, + "Variables": [ + ], + "AllowLoopback": true, + "Iterations": 5, + "RemoteReadyMatcher": "Started!", + "ResultsMatcher": ".*@ (.*) kbps.*", + "FailureDefault": "Result: 0 bytes @ 0 kbps (0.0 ms).", + "Formats": ["{0} kbps"], + "RegressionThreshold": "-60.0" } ] } diff --git a/src/platform/datapath_epoll.c b/src/platform/datapath_epoll.c index 013bcc8558..b485557186 100644 --- a/src/platform/datapath_epoll.c +++ b/src/platform/datapath_epoll.c @@ -1623,18 +1623,32 @@ CxPlatSocketHandleErrors( ErrNum, "Socket error event"); - // - // Send unreachable notification to MsQuic if any related - // errors were received. - // - if (ErrNum == ECONNREFUSED || - ErrNum == EHOSTUNREACH || - ErrNum == ENETUNREACH) { - if (!SocketContext->Binding->PcpBinding) { - SocketContext->Binding->Datapath->UdpHandlers.Unreachable( + if (SocketContext->Binding->Type == CXPLAT_SOCKET_UDP) { + // + // Send unreachable notification to MsQuic if any related + // errors were received. + // + if (ErrNum == ECONNREFUSED || + ErrNum == EHOSTUNREACH || + ErrNum == ENETUNREACH) { + if (!SocketContext->Binding->PcpBinding) { + SocketContext->Binding->Datapath->UdpHandlers.Unreachable( + SocketContext->Binding, + SocketContext->Binding->ClientContext, + &SocketContext->Binding->RemoteAddress); + } + } + } else if (ErrNum == ENOTSOCK || + ErrNum == EINTR || + ErrNum == ECANCELED || + ErrNum == ECONNABORTED || + ErrNum == ECONNRESET) { + if (!SocketContext->Binding->DisconnectIndicated) { + SocketContext->Binding->DisconnectIndicated = TRUE; + SocketContext->Binding->Datapath->TcpHandlers.Connect( SocketContext->Binding, SocketContext->Binding->ClientContext, - &SocketContext->Binding->RemoteAddress); + FALSE); } } } @@ -2257,6 +2271,13 @@ SocketSend( CxPlatSocketContextSetEvents(SocketContext, EPOLL_CTL_MOD, EPOLLIN | EPOLLOUT); Status = QUIC_STATUS_SUCCESS; } else { + if (Socket->Type != CXPLAT_SOCKET_UDP) { + SocketContext->Binding->Datapath->TcpHandlers.SendComplete( + SocketContext->Binding, + SocketContext->Binding->ClientContext, + errno, + SendData->TotalSize); + } CxPlatSendDataFree(SendData); } @@ -2516,14 +2537,10 @@ CxPlatSendDataSend( Status == EHOSTUNREACH || Status == ENETUNREACH) { if (!SocketContext->Binding->PcpBinding) { - if (SocketType == CXPLAT_SOCKET_UDP) { - SocketContext->Binding->Datapath->UdpHandlers.Unreachable( - SocketContext->Binding, - SocketContext->Binding->ClientContext, - &SocketContext->Binding->RemoteAddress); - } else { - // TODO - TCP error - } + SocketContext->Binding->Datapath->UdpHandlers.Unreachable( + SocketContext->Binding, + SocketContext->Binding->ClientContext, + &SocketContext->Binding->RemoteAddress); } } } @@ -2566,6 +2583,13 @@ CxPlatSocketContextFlushTxQueue( CxPlatLockAcquire(&SocketContext->TxQueueLock); CxPlatListRemoveHead(&SocketContext->TxQueue); + if (SocketContext->Binding->Type != CXPLAT_SOCKET_UDP) { + SocketContext->Binding->Datapath->TcpHandlers.SendComplete( + SocketContext->Binding, + SocketContext->Binding->ClientContext, + errno, + SendData->TotalSize); + } CxPlatSendDataFree(SendData); if (!CxPlatListIsEmpty(&SocketContext->TxQueue)) { SendData =