Android: Increase process start-up timeout for java_deobfuscate
And tweak the log message to not log "having to wait" when the process has died. Hit this timeout in the context of apk_operations.py, where it was creating the instance and then immediately sending a line to it. Change-Id: I6c3868b389bf4f7d6b6dbd37932a2f0dcecb2982 Reviewed-on: https://chromium-review.googlesource.com/676660 Reviewed-by: John Budorick <jbudorick@chromium.org> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#503748} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: ac1986b32351290a8a90d688f5604bca8d3a464b
This commit is contained in:
Родитель
aaf141004b
Коммит
99044bf6f9
|
@ -6,14 +6,16 @@ import logging
|
|||
import os
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from devil.utils import reraiser_thread
|
||||
from pylib import constants
|
||||
|
||||
|
||||
_MINIUMUM_TIMEOUT = 5.0 # Large enough to account for process start-up.
|
||||
_MINIUMUM_TIMEOUT = 3.0
|
||||
_PER_LINE_TIMEOUT = .002 # Should be able to process 500 lines per second.
|
||||
_PROCESS_START_TIMEOUT = 10.0
|
||||
|
||||
|
||||
class Deobfuscator(object):
|
||||
|
@ -27,6 +29,7 @@ class Deobfuscator(object):
|
|||
# Assign to None so that attribute exists if Popen() throws.
|
||||
self._proc = None
|
||||
# Start process eagerly to hide start-up latency.
|
||||
self._proc_start_time = time.time()
|
||||
self._proc = subprocess.Popen(
|
||||
cmd, bufsize=1, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
close_fds=True)
|
||||
|
@ -71,7 +74,7 @@ class Deobfuscator(object):
|
|||
break
|
||||
out_lines.append(line)
|
||||
|
||||
if not self.IsReady():
|
||||
if self.IsBusy():
|
||||
logging.warning('deobfuscator: Having to wait for Java deobfuscation.')
|
||||
|
||||
# Allow only one thread to operate at a time.
|
||||
|
@ -92,7 +95,9 @@ class Deobfuscator(object):
|
|||
self._proc.stdin.write('\n'.join(lines))
|
||||
self._proc.stdin.write('\n{}\n'.format(eof_line))
|
||||
self._proc.stdin.flush()
|
||||
timeout = max(_MINIUMUM_TIMEOUT, len(lines) * _PER_LINE_TIMEOUT)
|
||||
time_since_proc_start = time.time() - self._proc_start_time
|
||||
timeout = (max(0, _PROCESS_START_TIMEOUT - time_since_proc_start) +
|
||||
max(_MINIUMUM_TIMEOUT, len(lines) * _PER_LINE_TIMEOUT))
|
||||
reader_thread.join(timeout)
|
||||
if self.IsClosed():
|
||||
logging.warning(
|
||||
|
|
Загрузка…
Ссылка в новой задаче