Skip to content

Commit

Permalink
review fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Sadokhov committed Jul 19, 2023
1 parent f1e9d07 commit 5f0e000
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion runtime/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ bool f$curl_setopt_array(curl_easy easy_id, const array<mixed> &options) noexcep
}

mixed f$curl_exec(curl_easy easy_id) noexcept {
constexpr double long_curl_query = 2 * 10e-2; // 0.2 sec
constexpr double long_curl_query = 1 * 10e-2; // 0.1 sec
auto *easy_context = get_context<EasyContext>(easy_id);
if (!easy_context) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion server/php-master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ WorkerType run_master() {
for (int i = 0; i < job_workers_to_kill; ++i) {
kill_worker(WorkerType::job_worker);
}
for (int i = 0; i < job_workers_to_run && !failed; ++i) {
for (int i = 0; i < job_workers_to_run; ++i) {
if (run_worker(WorkerType::job_worker)) {
tvkprintf(job_workers, 1, "launched new job worker with pid = %d\n", pid);
return WorkerType::job_worker;
Expand Down
21 changes: 10 additions & 11 deletions server/php-worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,42 @@ double PhpWorker::enter_lifecycle() noexcept {
}
on_wakeup();

tvkprintf(php_runner, 3, "PHP-worker [state = %d, php-script state = %d, conn status = %d] lifecycle [req_id = %016llx]\n",
state, php_script ? static_cast<int>(php_script->state) : -1, conn->status, req_id);
tvkprintf(php_runner, 3, "PHP-worker enter lifecycle [php-script state = %d, conn status = %d] lifecycle [req_id = %016llx]\n",
php_script ? static_cast<int>(php_script->state) : -1, conn->status, req_id);
paused = false;
do {
switch (state) {
case phpq_try_start:
tvkprintf(php_runner, 1, "PHP-worker try start [req_id = %016llx]\n", req_id);
state_try_start();
break;

case phpq_init_script:
tvkprintf(php_runner, 1, "PHP-worker init PHP-script [req_id = %016llx]\n", req_id);
state_init_script();
break;

case phpq_run:
tvkprintf(php_runner, 3, "execute PHP-worker [req_id = %016llx]\n", req_id);
state_run();
break;

case phpq_free_script:
get_utime_monotonic();
tvkprintf(php_runner, 1, "PHP-worker free PHP-script [query worked = %.5lf] [query waited for start = %.5lf] [req_id = %016llx]\n", precise_now - start_time, start_time - init_time, req_id);
state_free_script();
break;

case phpq_finish:
tvkprintf(php_runner, 1, "finish PHP-worker [req_id = %016llx]\n", req_id);
state_finish();
return 0;
}
get_utime_monotonic();
} while (!paused);

tvkprintf(php_runner, 3, "PHP-worker [state = %d, php-script state = %d, conn status = %d] return in net reactor [req_id = %016llx]\n",
state, php_script ? static_cast<int>(php_script->state) : -1, conn->status, req_id);
tvkprintf(php_runner, 3, "PHP-worker [php-script state = %d, conn status = %d] return in net reactor [req_id = %016llx]\n",
php_script ? static_cast<int>(php_script->state) : -1, conn->status, req_id);
assert(conn->status == conn_wait_net);
return get_timeout();
}
Expand All @@ -88,7 +94,6 @@ void PhpWorker::on_wakeup() noexcept {
}

void PhpWorker::state_try_start() noexcept {
tvkprintf(php_runner, 1, "PHP-worker try start [req_id = %016llx]\n", req_id);
if (terminate_flag) {
state = phpq_finish;
return;
Expand Down Expand Up @@ -140,7 +145,6 @@ void PhpWorker::state_init_script() noexcept {

get_utime_monotonic();
start_time = precise_now;
tvkprintf(php_runner, 1, "init PHP-script inside PHP-worker [req_id = %016llx]\n", req_id);
assert(active_worker == nullptr);
active_worker = this;
vk::singleton<ServerStats>::get().set_running_worker_status();
Expand Down Expand Up @@ -389,13 +393,8 @@ void PhpWorker::state_free_script() noexcept {
php_worker_run_flag = 0;
int f = 0;

get_utime_monotonic();
double worked = precise_now - start_time;
double waited = start_time - init_time;

assert(active_worker == this);
active_worker = nullptr;
tvkprintf(php_runner, 1, "PHP-worker free PHP-script [query worked = %.5lf] [query waited for start = %.5lf] [req_id = %016llx]\n", worked, waited, req_id);
vk::singleton<ServerStats>::get().set_idle_worker_status();
if (mode == once_worker) {
static int left = run_once_count;
Expand Down

0 comments on commit 5f0e000

Please sign in to comment.