Mercurial > hg-stable
comparison mercurial/debugcommands.py @ 36851:31581528f242
debugwireproto: close the write end before consuming all available data
And make it read all available data deterministically. Otherwise util.poll()
may deadlock because both stdout and stderr could have no data.
Spotted by the next patch which removes stderr from the fds.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 12 Mar 2018 22:47:33 +0900 |
parents | 5bc7ff103081 |
children | c92d1d3c58ee |
comparison
equal
deleted
inserted
replaced
36850:ff541b8cdee0 | 36851:31581528f242 |
---|---|
2688 Flush data written to the server. | 2688 Flush data written to the server. |
2689 | 2689 |
2690 readavailable | 2690 readavailable |
2691 ------------- | 2691 ------------- |
2692 | 2692 |
2693 Read all available data from the server. | 2693 Close the write end of the connection and read all available data from |
2694 the server. | |
2694 | 2695 |
2695 If the connection to the server encompasses multiple pipes, we poll both | 2696 If the connection to the server encompasses multiple pipes, we poll both |
2696 pipes and read available data. | 2697 pipes and read available data. |
2697 | 2698 |
2698 readline | 2699 readline |
2833 | 2834 |
2834 batchedcommands = None | 2835 batchedcommands = None |
2835 elif action == 'close': | 2836 elif action == 'close': |
2836 peer.close() | 2837 peer.close() |
2837 elif action == 'readavailable': | 2838 elif action == 'readavailable': |
2838 fds = [stdout.fileno(), stderr.fileno()] | 2839 stdin.close() |
2839 try: | 2840 stdout.read() |
2840 act = util.poll(fds) | 2841 stderr.read() |
2841 except NotImplementedError: | |
2842 # non supported yet case, assume all have data. | |
2843 act = fds | |
2844 | |
2845 if stdout.fileno() in act: | |
2846 util.readpipe(stdout) | |
2847 if stderr.fileno() in act: | |
2848 util.readpipe(stderr) | |
2849 elif action == 'readline': | 2842 elif action == 'readline': |
2850 stdout.readline() | 2843 stdout.readline() |
2851 else: | 2844 else: |
2852 raise error.Abort(_('unknown action: %s') % action) | 2845 raise error.Abort(_('unknown action: %s') % action) |
2853 | 2846 |