From 2c0965a1be2509406a86c48558a4a70681315dc0 Mon Sep 17 00:00:00 2001 From: Micheal X Date: Thu, 26 Oct 2023 23:05:42 +1300 Subject: [PATCH] 5.8.5 add debug log. --- code/default/lib/noarch/front_base/http1.py | 5 +++-- .../lib/noarch/front_base/http_common.py | 17 +++++++++++------ .../lib/noarch/front_base/http_dispatcher.py | 3 ++- code/default/lib/noarch/simple_http_client.py | 4 ++-- code/default/version.txt | 2 +- .../x_tunnel/local/seley_front/config.py | 2 +- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/code/default/lib/noarch/front_base/http1.py b/code/default/lib/noarch/front_base/http1.py index 88f29c7e9e..af1dc5f122 100644 --- a/code/default/lib/noarch/front_base/http1.py +++ b/code/default/lib/noarch/front_base/http1.py @@ -129,8 +129,9 @@ def work_loop(self): self.last_send_time = time_now self.last_recv_time = time_now - if self.processed_tasks > self.config.http1_max_process_tasks or self.is_life_end(): - self.close("lift end") + life_end_reason = self.is_life_end() + if life_end_reason: + self.close("life_end:" + life_end_reason) return def request_task(self, task): diff --git a/code/default/lib/noarch/front_base/http_common.py b/code/default/lib/noarch/front_base/http_common.py index 501f449f91..1eb8bcb5e3 100644 --- a/code/default/lib/noarch/front_base/http_common.py +++ b/code/default/lib/noarch/front_base/http_common.py @@ -312,14 +312,19 @@ def get_host(self, task_host): def is_life_end(self): now = time.time() if now > self.life_end_time: - return True + return "life_end_time" elif now - self.last_recv_time > 230: - return True + return "last_recv_time" elif self.continue_fail_tasks > self.config.dispather_worker_max_continue_fail: - return True + return "continue_fail" elif self.processed_tasks > self.config.http2_max_process_tasks: - return True - elif self.version == "1.1" and now - self.last_recv_time > self.config.http1_idle_time: - return True + return "processed_tasks" + elif self.version == "1.1": + if self.processed_tasks > self.config.http1_max_process_tasks: + return "http1 max_process_tasks" + elif now - self.last_recv_time > self.config.http1_idle_time: + return "http1 last_recv_time" + else: + return False else: return False diff --git a/code/default/lib/noarch/front_base/http_dispatcher.py b/code/default/lib/noarch/front_base/http_dispatcher.py index 0f7bbc3f89..2b370ce728 100644 --- a/code/default/lib/noarch/front_base/http_dispatcher.py +++ b/code/default/lib/noarch/front_base/http_dispatcher.py @@ -228,7 +228,8 @@ def _remove_life_end_workers(self): to_close.append(worker) for worker in to_close: - worker.close("life end") + reason = worker.is_life_end() + worker.close("life end:" + reason) if worker in self.workers: try: self.workers.remove(worker) diff --git a/code/default/lib/noarch/simple_http_client.py b/code/default/lib/noarch/simple_http_client.py index f30f4abe0f..1c90c26dce 100644 --- a/code/default/lib/noarch/simple_http_client.py +++ b/code/default/lib/noarch/simple_http_client.py @@ -150,7 +150,7 @@ def recv(self, to_read=8192, timeout=30.0): try: return self.sock.recv(to_read) except (BlockingIOError, socket.error) as e: - if e.errno in [2, 11, 35, 10035]: + if e.errno in [2, 11, 35, 60, 10035]: time_left = end_time - time.time() if time_left < 0: break @@ -315,7 +315,7 @@ def _read_size(self, read_len, timeout): try: nbytes = self.sock.recv_into(view[out_len:], to_read) except (BlockingIOError, socket.error) as e: - if e.errno in [2, 11, 35, 10035]: + if e.errno in [2, 11, 35, 60, 10035]: time_left = start_time + timeout - time.time() if time_left < 0: raise socket.timeout diff --git a/code/default/version.txt b/code/default/version.txt index ee108f47ac..a94a88fbb8 100644 --- a/code/default/version.txt +++ b/code/default/version.txt @@ -1 +1 @@ -5.8.4 \ No newline at end of file +5.8.5 \ No newline at end of file diff --git a/code/default/x_tunnel/local/seley_front/config.py b/code/default/x_tunnel/local/seley_front/config.py index d12142ffcb..ba799368cf 100644 --- a/code/default/x_tunnel/local/seley_front/config.py +++ b/code/default/x_tunnel/local/seley_front/config.py @@ -20,7 +20,7 @@ def __init__(self, fn): # http1 self.set_var("http1_first_ping_wait", 0) self.set_var("http1_ping_interval", 0) - self.set_var("http1_idle_time", 240) + self.set_var("http1_idle_time", 230) self.set_var("http1_max_process_tasks", 999999) self.set_var("http2_max_process_tasks", 999999) self.set_var("http2_status_to_close", [404])