Browse Source

Fix maxSize, maxTime, and maxMemory values of zero

master
JustAnotherArchivist 3 years ago
parent
commit
54b643c954
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      irclog.py
  2. +1
    -1
      nicegrep

+ 2
- 2
irclog.py View File

@@ -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:


+ 1
- 1
nicegrep View File

@@ -3,5 +3,5 @@
# Executes grep with the provided arguments using `nice -n NICE` and `ulimit -v MAXMEMORY`
nice="$1"; shift
maxMemory="$1"; shift
ulimit -v "${maxMemory}"
if [[ "${maxMemory}" != '0' ]]; then ulimit -v "${maxMemory}"; fi
exec nice -n "${nice}" grep "$@"

Loading…
Cancel
Save