Comments
Patch
@@ -495,7 +495,7 @@
_(b"connection closed early"),
)
size = int(line)
- data = pipe.read(size)
+ data = _readhugestream(pipe, size)
if len(data) != size:
raise error.ResponseError(
_(b"error downloading file contents:"),
@@ -664,3 +664,21 @@
b'excess remotefilelog fetching:\n%s\n',
b''.join(pycompat.sysbytes(s) for s in traceback.format_stack()),
)
+
+
+if pycompat.iswindows:
+ # read() deadlock on Windows when size is too big
+ def _readhugestream(stream, size):
+ maxchunksize = 4 * 1024
+ data = bytearray()
+
+ while len(data) < size:
+ datachunk = stream.read(min(size - len(data), maxchunksize))
+ data += datachunk
+ if not datachunk:
+ # Prevents a deadlock in case the pipe is empty
+ break
+ return pycompat.bytestr(data)
+else:
+ def _readhugestream(stream, size):
+ return stream.read(size)