diff --git a/src/bill/corebill.cpp b/src/bill/corebill.cpp index 1d508752..53a77f36 100644 --- a/src/bill/corebill.cpp +++ b/src/bill/corebill.cpp @@ -47,26 +47,24 @@ namespace corebill // Reset counter timestamp. stat.timestamp = time_now; } - else - { - // Check whether we have exceeded the threshold within the monitering interval. - const uint64_t elapsed_time = time_now - stat.timestamp; - if (elapsed_time <= VIOLATION_REFRESH_INTERVAL && stat.counter > VIOLATION_THRESHOLD) - { - // IP exceeded violation threshold. - stat.timestamp = 0; - stat.counter = 0; - std::scoped_lock gray_list_lock(graylist_mutex); - graylist.emplace(host, VIOLATION_REFRESH_INTERVAL); - LOG_WARNING << host << " placed on graylist."; - } - else if (elapsed_time > VIOLATION_REFRESH_INTERVAL) - { - // Start the counter fresh. - stat.timestamp = time_now; - stat.counter = 1; - } + // Check whether we have exceeded the threshold within the monitering interval. + const uint64_t elapsed_time = time_now - stat.timestamp; + if (elapsed_time <= VIOLATION_REFRESH_INTERVAL && stat.counter > VIOLATION_THRESHOLD) + { + // IP exceeded violation threshold. + + stat.timestamp = 0; + stat.counter = 0; + std::scoped_lock gray_list_lock(graylist_mutex); + graylist.emplace(host, VIOLATION_REFRESH_INTERVAL); + LOG_WARNING << host << " placed on graylist."; + } + else if (elapsed_time > VIOLATION_REFRESH_INTERVAL) + { + // Start the counter fresh. + stat.timestamp = time_now; + stat.counter = 1; } } diff --git a/src/comm/comm_session.cpp b/src/comm/comm_session.cpp index 25431242..d3b21890 100644 --- a/src/comm/comm_session.cpp +++ b/src/comm/comm_session.cpp @@ -275,25 +275,23 @@ namespace comm // Reset counter timestamp. t.timestamp = time_now; } - else + + // Check whether we have exceeded the threshold within the monitering interval. + const uint64_t elapsed_time = time_now - t.timestamp; + if (elapsed_time <= t.intervalms && t.counter_value > t.threshold_limit) { - // Check whether we have exceeded the threshold within the monitering interval. - const uint64_t elapsed_time = time_now - t.timestamp; - if (elapsed_time <= t.intervalms && t.counter_value > t.threshold_limit) - { - mark_for_closure(); + mark_for_closure(); - t.timestamp = 0; - t.counter_value = 0; + t.timestamp = 0; + t.counter_value = 0; - LOG_INFO << "Session " << display_name() << " threshold exceeded. (type:" << threshold_type << " limit:" << t.threshold_limit << ")"; - corebill::report_violation(host_address); - } - else if (elapsed_time > t.intervalms) - { - t.timestamp = time_now; - t.counter_value = amount; - } + LOG_INFO << "Session " << display_name() << " threshold exceeded. (type:" << threshold_type << " limit:" << t.threshold_limit << ")"; + corebill::report_violation(host_address); + } + else if (elapsed_time > t.intervalms) + { + t.timestamp = time_now; + t.counter_value = amount; } } diff --git a/src/comm/hpws.hpp b/src/comm/hpws.hpp index f5ec6deb..b6b63e4b 100644 --- a/src/comm/hpws.hpp +++ b/src/comm/hpws.hpp @@ -47,7 +47,7 @@ namespace hpws // used when waiting for messages that should already be on the pipe #define HPWS_SMALL_TIMEOUT 10 // used when waiting for server process to spawn -#define HPWS_LONG_TIMEOUT 50 +#define HPWS_LONG_TIMEOUT 1500 // This timeout has to account the possible delays in communication via internet. typedef union { diff --git a/test/bin/hpws b/test/bin/hpws index 6f508cec..f1d550b5 100755 Binary files a/test/bin/hpws and b/test/bin/hpws differ