Re: [PATCH v2] pipe_command(): mark stdin descriptor as non-blocking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 03.08.2022 um 19:20 schrieb Jeff King:
> On Wed, Aug 03, 2022 at 06:45:23PM +0200, René Scharfe wrote:
>
>>> +test_expect_success 'handle very large filtered diff' '
>>> +	git reset --hard &&
>>> +	# The specific number here is not important, but it must
>>> +	# be large enough that the output of "git diff --color"
>>> +	# fills up the pipe buffer. 10,000 results in ~200k of
>>> +	# colored output.
>>> +	test_seq 10000 >test &&
>>> +	false &&
>>
>> Isn't this test going to end here, reporting failure before it even gets
>> to the interesting part?
>
> Urgh, whoops. That was from some last-minute tweaking of the comment.
> There was also a line:
>
>   git diff --color | wc -c
>
> before it so I could measure how big the output was for a few values.
>
> It snuck into the emailed patch, but the actual test runs (including the
> Windows CI) didn't include that (since obviously they'd have failed the
> test).

Without that line the added test hangs for me on the Git for Windows
SDK on Windows 11.

With the patch below it fails and reports basically nothing:

   expecting success of 3701.57 'handle very large filtered diff':
           git reset --hard &&
           # The specific number here is not important, but it must
           # be large enough that the output of "git diff --color"
           # fills up the pipe buffer. 10,000 results in ~200k of
           # colored output.
           test_seq 10000 >test &&
           test_config interactive.diffFilter cat &&
           printf y >y &&
           force_color git add -p >output 2>&1 <y &&
           git diff-files --exit-code -- test

   HEAD is now at 095e8c6 main
   not ok 57 - handle very large filtered diff
   #
   #               git reset --hard &&
   #               # The specific number here is not important, but it must
   #               # be large enough that the output of "git diff --color"
   #               # fills up the pipe buffer. 10,000 results in ~200k of
   #               # colored output.
   #               test_seq 10000 >test &&
   #               test_config interactive.diffFilter cat &&
   #               printf y >y &&
   #               force_color git add -p >output 2>&1 <y &&
   #               git diff-files --exit-code -- test
   #
   1..57

The file "output" contains "error: failed to run 'cat'".  This is
add-patch.c::parse_diff() reporting that pipe_command() failed.  So
that's not it, yet.  (I don't actually know what I'm doing here.)

---
 compat/nonblock.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/compat/nonblock.c b/compat/nonblock.c
index 897c099010..030cf92af2 100644
--- a/compat/nonblock.c
+++ b/compat/nonblock.c
@@ -14,8 +14,21 @@ int enable_nonblock(int fd)

 #else

+#include "win32.h"
+
 int enable_nonblock(int fd)
 {
+	DWORD mode;
+	HANDLE handle = winansi_get_osfhandle(fd);
+	if (!handle)
+		return -1;
+	if (!GetNamedPipeHandleState(handle, &mode, NULL, NULL, NULL, NULL, 0))
+		return -1;
+	if (mode & PIPE_NOWAIT)
+		return 0;
+	mode |= PIPE_NOWAIT;
+	if (!SetNamedPipeHandleState(handle, &mode, NULL, NULL))
+		return -1;
 	return 0;
 }

--
2.37.1.windows.1






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux