mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
48e4137eba
commit
e5fb6e585f
@ -38,6 +38,8 @@ import tempfile
|
||||
import threading
|
||||
|
||||
|
||||
# Timeout when sending events via socket (applies to connect, send)
|
||||
SOCK_TIMEOUT = 0.5 # in seconds
|
||||
# BaseEventLog __init__ Counter that is consistent within the same process
|
||||
p_init_count = 0
|
||||
|
||||
@ -296,6 +298,7 @@ class BaseEventLog:
|
||||
with socket.socket(
|
||||
socket.AF_UNIX, socket.SOCK_STREAM
|
||||
) as sock:
|
||||
sock.settimeout(SOCK_TIMEOUT)
|
||||
sock.connect(path)
|
||||
self._WriteLog(sock.sendall)
|
||||
return f"af_unix:stream:{path}"
|
||||
|
Loading…
Reference in New Issue
Block a user