|
|
@@ -995,7 +995,7 @@ class WebServer: |
|
|
|
incomplete = False |
|
|
|
while (buf := await proc.stdout.read(1024)): |
|
|
|
self.logger.debug(f'Request {id(request)} grep stdout: {buf!r}') |
|
|
|
if size + len(buf) > self.config['web']['search']['maxSize']: |
|
|
|
if self.config['web']['search']['maxSize'] != 0 and size + len(buf) > self.config['web']['search']['maxSize']: |
|
|
|
self.logger.warning(f'Request {id(request)} grep output exceeds max size') |
|
|
|
if (bufLFPos := buf.rfind(b'\n', 0, self.config['web']['search']['maxSize'] - size)) > -1: |
|
|
|
# There's a LF in this buffer at the right position, keep everything up to it such that the total size is <= maxSize. |
|
|
@@ -1031,7 +1031,7 @@ class WebServer: |
|
|
|
|
|
|
|
stdoutTask = asyncio.create_task(process_stdout()) |
|
|
|
stderrTask = asyncio.create_task(process_stderr()) |
|
|
|
await asyncio.wait({stdoutTask, stderrTask}, timeout = self.config['web']['search']['maxTime']) |
|
|
|
await asyncio.wait({stdoutTask, stderrTask}, timeout = self.config['web']['search']['maxTime'] if self.config['web']['search']['maxTime'] != 0 else None) |
|
|
|
# The stream readers may quit before the process is done even on a successful grep. Wait a tiny bit longer for the process to exit. |
|
|
|
await asyncio.wait({asyncio.create_task(proc.wait())}, timeout = 0.1) |
|
|
|
if proc.returncode is None: |
|
|
|