tools/qvm-run: fix handling small data blocks

When data block is smaller than 4096 (and no EOF is reached), python's
io.read() will call read(2) again to get more data. This may deadlock if
the other end of connection will write anything only after receiveing
data (which is the case for qubes.Filecopy).
Disable this buffering by using syscall wrappers directly. To not affect
performance that much, increase buffer size to 64k.

Fixes QubesOS/qubes-issues#2948
Este commit está contenido en:
Marek Marczykowski-Górecki 2017-08-02 02:43:03 +02:00
padre 1d29929ae1
commit 50bd9f5fab
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 063938BA42CFA724

Ver fichero

@ -94,11 +94,12 @@ parser.add_argument('cmd', metavar='COMMAND',
def copy_stdin(stream):
'''Copy stdin to *stream*'''
# multiprocessing.Process have sys.stdin connected to /dev/null
stdin = open(0)
for data in iter(lambda: stdin.buffer.read(4096), b''):
os.set_blocking(0, True)
for data in iter(lambda: os.read(0, 65536), b''):
if data is None:
break
stream.write(data)
stream.flush()
stream.close()
def main(args=None, app=None):