Mercurial > public > mercurial-scm > hg
comparison mercurial/hook.py @ 30364:ad56204f733e
hook: flush stdout before restoring stderr redirection
There was a similar issue to 8b011ededfb2. If an in-process hook writes
to stdout, the data may be buffered. In which case, stdout must be flushed
before restoring its file descriptor. Otherwise, remaining data would be sent
over the ssh wire and corrupts the protocol.
Note that this is a different redirection from the one I've just removed.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 08 Nov 2016 22:22:22 +0900 |
parents | a1259e502bdf |
children | 5564fcd031df |
comparison
equal
deleted
inserted
replaced
30363:a1259e502bdf | 30364:ad56204f733e |
---|---|
256 # A forcible flush is required to make small stderr data in the | 256 # A forcible flush is required to make small stderr data in the |
257 # remote side available to the client immediately. | 257 # remote side available to the client immediately. |
258 sys.stderr.flush() | 258 sys.stderr.flush() |
259 finally: | 259 finally: |
260 if _redirect and oldstdout >= 0: | 260 if _redirect and oldstdout >= 0: |
261 sys.__stdout__.flush() # write hook output to stderr fd | |
261 os.dup2(oldstdout, stdoutno) | 262 os.dup2(oldstdout, stdoutno) |
262 os.close(oldstdout) | 263 os.close(oldstdout) |
263 | 264 |
264 return res | 265 return res |