Commit e378f7e4 authored by jan.koester's avatar jan.koester
Browse files

test

parent e0f9f2c2
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include <algorithm>
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <memory>
#include <vector>
@@ -621,7 +622,7 @@ namespace netplus {
            if (idleTimeoutSeconds <= 0) return;

            time_t now = time(nullptr);
            if (now - _lastSweepAttempt < kIdleSweepIntervalSeconds) return;
            if (now - _lastSweepAttempt < sweepIntervalSeconds()) return;
            _lastSweepAttempt = now;

            std::vector<int> idleFds;
@@ -644,6 +645,25 @@ namespace netplus {
        socket* _ServerSocket;
        time_t _lastSweepAttempt = 0;
        static constexpr int kIdleSweepIntervalSeconds = 30;

        // Test-only escape hatch, same precedent as QUIC_TRACE in quic.cpp: a real
        // production deployment never sets this, so sweepIntervalSeconds() returns
        // kIdleSweepIntervalSeconds (30) unconditionally there. It exists so the
        // idle-reaper regression test doesn't have to block for a real 30s per run
        // just to observe one sweep -- without it, the throttle above (deliberately
        // coarse so a busy listener isn't rescanning its whole CONNECTIONS registry
        // every event-loop timeout) would make the feature effectively untestable
        // in a normal test-suite time budget.
        static int sweepIntervalSeconds() {
            static const int v = []() -> int {
                if (const char* env = std::getenv("NETPLUS_IDLE_SWEEP_INTERVAL_SECONDS")) {
                    int parsed = std::atoi(env);
                    if (parsed > 0) return parsed;
                }
                return kIdleSweepIntervalSeconds;
            }();
            return v;
        }
    };

    // ------------------------------------------------------------
+21 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include <algorithm>
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <memory>
#include <vector>
@@ -732,7 +733,7 @@ namespace netplus {
            if (idleTimeoutSeconds <= 0) return;

            time_t now = time(nullptr);
            if (now - _lastSweepAttempt < kIdleSweepIntervalSeconds) return;
            if (now - _lastSweepAttempt < sweepIntervalSeconds()) return;
            _lastSweepAttempt = now;

            std::vector<int> idleFds;
@@ -757,6 +758,25 @@ namespace netplus {
        KeventBatch _batch;
        time_t _lastSweepAttempt = 0;
        static constexpr int kIdleSweepIntervalSeconds = 30;

        // Test-only escape hatch, same precedent as QUIC_TRACE in quic.cpp: a real
        // production deployment never sets this, so sweepIntervalSeconds() returns
        // kIdleSweepIntervalSeconds (30) unconditionally there. It exists so the
        // idle-reaper regression test doesn't have to block for a real 30s per run
        // just to observe one sweep -- without it, the throttle above (deliberately
        // coarse so a busy listener isn't rescanning its whole CONNECTIONS registry
        // every event-loop timeout) would make the feature effectively untestable
        // in a normal test-suite time budget. Mirrors epoll.cpp's identical helper.
        static int sweepIntervalSeconds() {
            static const int v = []() -> int {
                if (const char* env = std::getenv("NETPLUS_IDLE_SWEEP_INTERVAL_SECONDS")) {
                    int parsed = std::atoi(env);
                    if (parsed > 0) return parsed;
                }
                return kIdleSweepIntervalSeconds;
            }();
            return v;
        }
    };

    // ------------------------------------------------------------