Skip to content

feat: add worker on or off#166

Open
stepanrodimanov wants to merge 3 commits into
traffic_filteringfrom
add_worker_on_off
Open

feat: add worker on or off#166
stepanrodimanov wants to merge 3 commits into
traffic_filteringfrom
add_worker_on_off

Conversation

@stepanrodimanov
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread worker/include/worker.hpp
int64_t stats_interval = MIN_STATS_TIME;
int64_t filtering_check_interval = MIN_FILTERING_CHECK_TIME;

bool enable = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно хотя бы volatle, если не защищаем переменную примитивами синхронизации. Но по-хорошему изменения всех полей класса нужно защитить потокобезопасным кодом.

Comment thread worker/src/worker.cpp
last_filtering_check_time = now;
filtering_check_interval =
MIN_FILTERING_CHECK_TIME +
(rand() % (MAX_FILTERING_CHECK_TIME - MIN_FILTERING_CHECK_TIME + 1));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это зачем такое?

Comment thread worker/src/worker.cpp

int64_t seconds_since_filtering = (now - last_filtering_check_time) / 1s;
if (seconds_since_filtering >= filtering_check_interval) {
std::thread([this]() { checkFilteringStatus(); }).detach();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потеряем контроль над потоком, нужно иметь возможность его убивать.
Опрос, думаю, что можем оставить, хотя я бы включил этот флаг в политику фильтрации. Мы все равно обновляем политики, так можно и этот параметр проверять.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants