diff --git a/irclog.py b/irclog.py index 86221aa..689c78d 100644 --- a/irclog.py +++ b/irclog.py @@ -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: diff --git a/nicegrep b/nicegrep index 8b9ed18..3294657 100755 --- a/nicegrep +++ b/nicegrep @@ -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 "$@"