summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosip Sokcevic <sokcevic@google.com>2023-12-19 09:45:44 -0800
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-12-19 19:38:52 +0000
commite5fb6e585f593162ee2b10ad64cdd7ea2a577a06 (patch)
treed2a8825a34ef6c1df3dbadd5ff09d3196f89fa44
parent48e4137eba1678c40a4caa92d9148a9ade76ec90 (diff)
downloadgit-repo-e5fb6e585f593162ee2b10ad64cdd7ea2a577a06.tar.gz
git_trace2: Add socket timeout
repo blocks indefinitely until trace collector receives trace events, which is not desired. This change adds a fixed timeout to connect and send operations. It is possible that some events will be lost. repo logs any failed trace operation. Bug: b/316227772 Change-Id: I017636421b8e22ae3fcbab9e4eb2bee1d4fbbff4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/398717 Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Jason Chang <jasonnc@google.com>
-rw-r--r--git_trace2_event_log_base.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/git_trace2_event_log_base.py b/git_trace2_event_log_base.py
index f5424249..2f1aac76 100644
--- a/git_trace2_event_log_base.py
+++ b/git_trace2_event_log_base.py
@@ -38,6 +38,8 @@ import tempfile
38import threading 38import threading
39 39
40 40
41# Timeout when sending events via socket (applies to connect, send)
42SOCK_TIMEOUT = 0.5 # in seconds
41# BaseEventLog __init__ Counter that is consistent within the same process 43# BaseEventLog __init__ Counter that is consistent within the same process
42p_init_count = 0 44p_init_count = 0
43 45
@@ -296,6 +298,7 @@ class BaseEventLog:
296 with socket.socket( 298 with socket.socket(
297 socket.AF_UNIX, socket.SOCK_STREAM 299 socket.AF_UNIX, socket.SOCK_STREAM
298 ) as sock: 300 ) as sock:
301 sock.settimeout(SOCK_TIMEOUT)
299 sock.connect(path) 302 sock.connect(path)
300 self._WriteLog(sock.sendall) 303 self._WriteLog(sock.sendall)
301 return f"af_unix:stream:{path}" 304 return f"af_unix:stream:{path}"