From 92b9ef895052ee9ca843b32f5c2226d4e6a0dc25 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel <67607049+kpschoedel@users.noreply.github.com> Date: Tue, 21 Dec 2021 20:45:39 -0500 Subject: [PATCH] Remove INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS (#13188) #### Problem The option `INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS` is not enabled by any configuration in tree, and clutters up TCP code. Fixes #12939 INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS unused #### Change overview - Remove `INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS` and associated code #### Testing CI/build. No functional change since the option is unused. --- src/inet/InetConfig.h | 19 --------- src/inet/TCPEndPoint.cpp | 33 +--------------- src/inet/TCPEndPoint.h | 60 +---------------------------- src/inet/TCPEndPointImplLwIP.cpp | 7 ---- src/inet/TCPEndPointImplSockets.cpp | 55 ++------------------------ 5 files changed, 7 insertions(+), 167 deletions(-) diff --git a/src/inet/InetConfig.h b/src/inet/InetConfig.h index 2e69398afbb8ef..d209328fde87a5 100644 --- a/src/inet/InetConfig.h +++ b/src/inet/InetConfig.h @@ -192,25 +192,6 @@ #define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 1 #endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT -/** - * @def INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - * - * @brief - * When this flag is set, the InetLayer enables - * callbacks to the upper layer notifying it when - * the send channel of the TCP connection changes - * between being idle or not idle. - * - * @note - * When enabled, the TCP send queue is actively - * polled to determine if sent data has been - * acknowledged. - * - */ -#ifndef INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS -#define INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS 0 -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - /** * @def INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC * diff --git a/src/inet/TCPEndPoint.cpp b/src/inet/TCPEndPoint.cpp index b60a735769b546..de54ece03f2a18 100644 --- a/src/inet/TCPEndPoint.cpp +++ b/src/inet/TCPEndPoint.cpp @@ -467,40 +467,9 @@ void TCPEndPoint::ScheduleNextTCPUserTimeoutPoll(uint32_t aTimeOut) GetSystemLayer().StartTimer(System::Clock::Milliseconds32(aTimeOut), TCPUserTimeoutHandler, this); } -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS -void TCPEndPoint::SetTCPSendIdleAndNotifyChange(bool aIsTCPSendIdle) -{ - if (mIsTCPSendIdle != aIsTCPSendIdle) - { - ChipLogDetail(Inet, "TCP con send channel idle state changed : %s", aIsTCPSendIdle ? "false->true" : "true->false"); - - // Set the current Idle state - mIsTCPSendIdle = aIsTCPSendIdle; - - if (OnTCPSendIdleChanged) - { - OnTCPSendIdleChanged(this, mIsTCPSendIdle); - } - } -} -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - void TCPEndPoint::StartTCPUserTimeoutTimer() { - uint32_t timeOut = mUserTimeoutMillis; - -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - // Set timeout to the poll interval - - timeOut = mTCPSendQueuePollPeriodMillis; - - // Reset the poll count - - mTCPSendQueueRemainingPollCount = MaxTCPSendQueuePolls(); -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - - ScheduleNextTCPUserTimeoutPoll(timeOut); - + ScheduleNextTCPUserTimeoutPoll(mUserTimeoutMillis); mUserTimeoutTimerRunning = true; } diff --git a/src/inet/TCPEndPoint.h b/src/inet/TCPEndPoint.h index 4f1b479a2760c8..7c17055f833f4d 100644 --- a/src/inet/TCPEndPoint.h +++ b/src/inet/TCPEndPoint.h @@ -533,28 +533,6 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis */ OnAcceptErrorFunct OnAcceptError; -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - /** - * @brief Type of TCP SendIdle changed signal handling function. - * - * @param[in] endPoint The TCP endpoint associated with the event. - * - * @param[in] isIdle True if the send channel of the TCP endpoint - * is Idle, otherwise false. - * @details - * Provide a function of this type to the \c OnTCPSendIdleChanged delegate - * member to process the event of the send channel of the TCPEndPoint - * changing state between being idle and not idle. - */ - typedef void (*OnTCPSendIdleChangedFunct)(TCPEndPoint * endPoint, bool isIdle); - - /** The event handling function delegate of the endpoint signaling when the - * idleness of the TCP connection's send channel changes. This is utilized - * by upper layers to take appropriate actions based on whether sent data - * has been reliably delivered to the peer. */ - OnTCPSendIdleChangedFunct OnTCPSendIdleChanged; -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - /** * Size of the largest TCP packet that can be received. */ @@ -571,13 +549,6 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis #if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT , mUserTimeoutMillis(INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC), mUserTimeoutTimerRunning(false) -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - , - mIsTCPSendIdle(true), mTCPSendQueuePollPeriodMillis(INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC), - mTCPSendQueueRemainingPollCount( - MaxTCPSendQueuePolls(INET_CONFIG_DEFAULT_TCP_USER_TIMEOUT_MSEC, INET_CONFIG_TCP_SEND_QUEUE_POLL_INTERVAL_MSEC)), - OnTCPSendIdleChanged(nullptr) -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS #endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT {} @@ -619,44 +590,17 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis // return an error; zero means use system defaults. #if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT - uint32_t mUserTimeoutMillis; // The configured TCP user timeout value in milliseconds. - // If 0, assume not set. -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - bool mIsTCPSendIdle; // Indicates whether the send channel of the TCPEndPoint is Idle. - - uint16_t mTCPSendQueueRemainingPollCount; // The current remaining number of TCP SendQueue polls before - // the TCP User timeout period is reached. - - uint32_t mTCPSendQueuePollPeriodMillis; // The configured period of active polling of the TCP - // SendQueue. If 0, assume not set. - void SetTCPSendIdleAndNotifyChange(bool aIsSendIdle); - -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - + uint32_t mUserTimeoutMillis; // The configured TCP user timeout value in milliseconds. + // If 0, assume not set. bool mUserTimeoutTimerRunning; // Indicates whether the TCP UserTimeout timer has been started. static void TCPUserTimeoutHandler(chip::System::Layer * aSystemLayer, void * aAppState); virtual void TCPUserTimeoutHandler() = 0; void StartTCPUserTimeoutTimer(); - void StopTCPUserTimeoutTimer(); - void RestartTCPUserTimeoutTimer(); - void ScheduleNextTCPUserTimeoutPoll(uint32_t aTimeOut); - -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - static constexpr uint16_t MaxTCPSendQueuePolls(uint16_t userTimeout, uint16_t pollPeriod) - { - // If the UserTimeout is configured less than or equal to the poll interval, - // return 1 to poll at least once instead of returning zero and timing out - // immediately. - return (userTimeout > pollPeriod) ? (userTimeout / pollPeriod) : 1; - } - uint16_t MaxTCPSendQueuePolls(void) { return MaxTCPSendQueuePolls(mUserTimeoutMillis, mTCPSendQueuePollPeriodMillis); } -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - #endif // INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT TCPEndPoint(const TCPEndPoint &) = delete; diff --git a/src/inet/TCPEndPointImplLwIP.cpp b/src/inet/TCPEndPointImplLwIP.cpp index 88cb6fc0c55b34..6fb08a8ffd3d1a 100644 --- a/src/inet/TCPEndPointImplLwIP.cpp +++ b/src/inet/TCPEndPointImplLwIP.cpp @@ -683,14 +683,7 @@ void TCPEndPointImplLwIP::HandleDataSent(uint16_t lenSent) if (RemainingToSend() == 0) { // If the output queue has been flushed then stop the timer. - StopTCPUserTimeoutTimer(); - -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - // Notify up if all outstanding data has been acknowledged - - SetTCPSendIdleAndNotifyChange(true); -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS } else { diff --git a/src/inet/TCPEndPointImplSockets.cpp b/src/inet/TCPEndPointImplSockets.cpp index 199628cfecc7e7..d5d41fcc98afa1 100644 --- a/src/inet/TCPEndPointImplSockets.cpp +++ b/src/inet/TCPEndPointImplSockets.cpp @@ -556,12 +556,6 @@ CHIP_ERROR TCPEndPointImplSockets::DriveSendingImpl() OnDataSent(this, lenSent); } -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - // TCP Send is not Idle; Set state and notify if needed - - SetTCPSendIdleAndNotifyChange(false); -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - #if INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT mBytesWrittenSinceLastProbe += lenSent; @@ -675,27 +669,12 @@ void TCPEndPointImplSockets::TCPUserTimeoutHandler() // Set the timer running flag to false mUserTimeoutTimerRunning = false; - CHIP_ERROR err = CHIP_NO_ERROR; bool isProgressing = false; - err = CheckConnectionProgress(isProgressing); - SuccessOrExit(err); + CHIP_ERROR err = CheckConnectionProgress(isProgressing); - if (mLastTCPKernelSendQueueLen == 0) - { -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - // If the kernel TCP send queue as well as the TCPEndPoint - // send queue have been flushed then notify application - // that all data has been acknowledged. - - if (mSendQueue.IsNull()) - { - SetTCPSendIdleAndNotifyChange(true); - } -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - } - else - // There is data in the TCP Send Queue + if (err == CHIP_NO_ERROR && mLastTCPKernelSendQueueLen != 0) { + // There is data in the TCP Send Queue if (isProgressing) { // Data is flowing, so restart the UserTimeout timer @@ -706,31 +685,14 @@ void TCPEndPointImplSockets::TCPUserTimeoutHandler() } else { -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - // Data flow is not progressing. - // Decrement the remaining max TCP send queue polls. - - mTCPSendQueueRemainingPollCount--; - - VerifyOrExit(mTCPSendQueueRemainingPollCount != 0, err = INET_ERROR_TCP_USER_TIMEOUT); - - // Restart timer to poll again - - ScheduleNextTCPUserTimeoutPoll(mTCPSendQueuePollPeriodMillis); -#else // Close the connection as the TCP UserTimeout has expired - - ExitNow(err = INET_ERROR_TCP_USER_TIMEOUT); -#endif // !INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS + err = INET_ERROR_TCP_USER_TIMEOUT; } } -exit: - if (err != CHIP_NO_ERROR) { // Close the connection as the TCP UserTimeout has expired - DoClose(err, false); } } @@ -963,15 +925,6 @@ void TCPEndPointImplSockets::ReceiveData() // If the output queue has been flushed then stop the timer. StopTCPUserTimeoutTimer(); - -#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS - // Notify up if all outstanding data has been acknowledged - - if (mSendQueue.IsNull()) - { - SetTCPSendIdleAndNotifyChange(true); - } -#endif // INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS } else if (isProgressing && mUserTimeoutTimerRunning) {