1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-11 00:58:39 +03:00

Backport fix time reporting of connection fix

This commit is contained in:
Adolfo Gómez García 2023-01-09 14:27:15 +01:00
parent 0a15f7bdce
commit da02ad0c7c
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 11 additions and 6 deletions

View File

@ -70,8 +70,8 @@ class StatsManager:
last_recv: int
recv: int
last: float
start: float # timestamp
end: float
start_time: float # timestamp
end_time: float
def __init__(self, ns: 'Namespace'):
self.ns = ns
@ -80,8 +80,13 @@ class StatsManager:
self.sent = self.last_sent = 0
self.recv = self.last_recv = 0
self.last = time.monotonic()
self.start = time.monotonic()
self.end = self.start
self.start_time = time.monotonic()
self.end_time = self.start_time
@property
def current_time(self) -> float:
return time.monotonic()
def update(self, force: bool = False):
now = time.monotonic()
@ -111,7 +116,7 @@ class StatsManager:
def close(self):
self.update(True)
self.ns.current -= 1
self.end = time.monotonic()
self.end_time = time.monotonic()
# Stats collector thread
class GlobalStats:

View File

@ -283,7 +283,7 @@ class TunnelProtocol(asyncio.Protocol):
self.pretty_destination(),
self.stats_manager.sent,
self.stats_manager.recv,
int(self.stats_manager.end - self.stats_manager.start),
int(self.stats_manager.current_time - self.stats_manager.start_time),
)
# Notify end to uds, using a task becase we are not an async function
asyncio.get_event_loop().create_task(