summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0889
blob: 53b724cbefa07ba4049281896e8bc2546ea8b33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0889
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0889
Problem:    MS-Windows: a channel write may hang.
Solution:   Check for WriteFile() not writing anything. (Yasuhiro Matsumoto,
            closes #3920)
Files:	    src/channel.c, src/testdir/test_channel.vim,
            src/testdir/test_channel_pipe.py


*** ../vim-8.1.0888/src/channel.c	2019-02-08 12:46:03.584784210 +0100
--- src/channel.c	2019-02-10 22:23:11.048518527 +0100
***************
*** 91,99 ****
  	    size = MAX_NAMED_PIPE_SIZE;
  	else
  	    size = (DWORD)todo;
! 	// If the pipe overflows while the job does not read the data, WriteFile
! 	// will block forever. This abandons the write.
  	memset(&ov, 0, sizeof(ov));
  	if (!WriteFile(h, buf + done, size, &nwrite, &ov))
  	{
  	    DWORD err = GetLastError();
--- 91,100 ----
  	    size = MAX_NAMED_PIPE_SIZE;
  	else
  	    size = (DWORD)todo;
! 	// If the pipe overflows while the job does not read the data,
! 	// WriteFile() will block forever. This abandons the write.
  	memset(&ov, 0, sizeof(ov));
+ 	nwrite = 0;
  	if (!WriteFile(h, buf + done, size, &nwrite, &ov))
  	{
  	    DWORD err = GetLastError();
***************
*** 104,109 ****
--- 105,114 ----
  		return -1;
  	    FlushFileBuffers(h);
  	}
+ 	else if (nwrite == 0)
+ 	    // WriteFile() returns TRUE but did not write anything. This causes
+ 	    // a hang, so bail out.
+ 	    break;
  	todo -= nwrite;
  	done += nwrite;
      }
*** ../vim-8.1.0888/src/testdir/test_channel.vim	2019-01-31 15:52:05.269907631 +0100
--- src/testdir/test_channel.vim	2019-02-10 22:16:00.363647792 +0100
***************
*** 2003,2008 ****
--- 2003,2022 ----
    endtry
  endfunc
  
+ func Test_no_hang_windows()
+   if !has('job') || !has('win32')
+     return
+   endif
+ 
+   try
+     let job = job_start(s:python . " test_channel_pipe.py busy",
+           \ {'mode': 'raw', 'drop': 'never', 'noblock': 0})
+     call assert_fails('call ch_sendraw(job, repeat("X", 80000))', 'E631:')
+   finally
+     call job_stop(job)
+   endtry
+ endfunc
+ 
  func Test_job_exitval_and_termsig()
    if !has('unix')
      return
*** ../vim-8.1.0888/src/testdir/test_channel_pipe.py	2019-01-24 23:11:44.635650160 +0100
--- src/testdir/test_channel_pipe.py	2019-02-10 22:16:00.363647792 +0100
***************
*** 18,23 ****
--- 18,26 ----
              print(sys.argv[1], end='')
              sys.stdout.flush()
              sys.exit(0)
+         elif sys.argv[1].startswith("busy"):
+             time.sleep(100)
+             sys.exit(0)
          else:
              print(sys.argv[1])
              sys.stdout.flush()
*** ../vim-8.1.0888/src/version.c	2019-02-10 22:14:24.184352831 +0100
--- src/version.c	2019-02-10 22:17:35.942949889 +0100
***************
*** 785,786 ****
--- 785,788 ----
  {   /* Add new patch number below this line */
+ /**/
+     889,
  /**/

-- 
   [The rest of the ARMY stand around looking at a loss.]
INSPECTOR END OF FILM: (picks up megaphone) All right!  Clear off!  Go on!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///