Loading src/event/epoll.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; Loading @@ -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; } }; // ------------------------------------------------------------ Loading src/event/kqueue.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; Loading @@ -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; } }; // ------------------------------------------------------------ Loading Loading
src/event/epoll.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; Loading @@ -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; } }; // ------------------------------------------------------------ Loading
src/event/kqueue.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; Loading @@ -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; } }; // ------------------------------------------------------------ Loading