[PATCH v8] Cygwin: pipe: Switch pipe mode to blocking mode by default

Takashi Yano takashi.yano@nifty.ne.jp
Sun Oct 27 08:57:22 GMT 2024


Hi Corinna,

On Thu, 24 Oct 2024 12:21:04 +0200
Corinna Vinschen wrote:
> > > Before:
> > > 
> > >   $ ./x 40000
> > >   pipe capacity: 65536
> > >   write: writable 1, 40000 25536
> > >   write: writable 1, 24576 960
> > >   write: writable 0, 512 448
> > >   write: writable 0, 256 192
> > >   write: writable 0, 128 64
> > >   write: writable 0, 64 0
> > >   write: writable 0, -1 / Resource temporarily unavailable
> > > 
> > > After:
> > > 
> > >   $ ./x 40000
> > >   pipe capacity: 65536
> > >   write: writable 1, 40000 25536
> > >   write: writable 1, 25536 0
> > >   write: writable 0, -1 / Resource temporarily unavailable
> > > 
> > > This way, we get into the EAGAIN case much faster again, which was
> > > one reason for 170e6badb621.
> > > 
> > > Does this make more sense, and if so, why?  If this is really the
> > > way to go, the comment starting at line 634 (after applying your patch)
> > > will have to be changed as well.
> > 
> > Perhaps, I did not understand intent of 170e6badb621. Could you please
> > provide the test program (./x)? I will check my code.
> 
> I attached it.  If you call it with just the number of bytes per write,
> e.g. `./x 12345', the writes are blocking.  If you add another parameter,
> e.g. `./x 12345 1', the writes are nonblocking.

Thanks for the test case.
I think I could restore the previous behaviour. Please try v9 patch.

CYGWIN_NT-10.0-19045 HP-Z230 3.5.4-1.x86_64 2024-08-25 16:52 UTC x86_64 Cygwin
$ ./a.exe 40000 1
pipe capacity: 65536
write: writable 1, 40000 25536
write: writable 1, 24576 960
write: writable 0, -1 / Resource temporarily unavailable

Just after the commit 170e6badb621 (master branch)
$ ./a.exe 40000 1
pipe capacity: 65536
write: writable 1, 40000 25536
write: writable 1, 24576 960
write: writable 0, -1 / Resource temporarily unavailable

With v8 patch:
$ ./a.exe 40000 1
pipe capacity: 65536
write: writable 1, 40000 25536
write: writable 1, 25536 0
write: writable 0, -1 / Resource temporarily unavailable

With v9 patch:
$ ./a.exe 40000 1
pipe capacity: 65536
write: writable 1, 40000 25536
write: writable 1, 24576 960
write: writable 0, -1 / Resource temporarily unavailable

However, I am not sure if this is the right thing.
In Linux (debian), I got the same result as above:
Linux debian2 6.1.0-26-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 (2024-09-30) x86_64 GNU/Linux
$ ./a.out 40000 1
pipe capacity: 65536
write: writable 1, 40000 25536
write: writable 1, 24576 960
write: writable 0, -1 / Resource temporarily unavailable

But, even with v9 patch, the behaviour is not same as linux for another
case.

Please try:
$ ./a.out `expr 65536 - 4096 + 543` 1
pipe capacity: 65536
write: writable 1, 61983 3553
write: writable 0, 543 3010
write: writable 0, 543 2467
write: writable 0, 543 1924
write: writable 0, 543 1381
write: writable 0, 543 838
write: writable 0, 543 295
write: writable 0, -1 / Resource temporarily unavailable

$ ./a.out `expr 65536 - 4096 + 1234` 1
pipe capacity: 65536
write: writable 1, 62674 2862
write: writable 0, 1234 1628
write: writable 0, 1234 394
write: writable 0, -1 / Resource temporarily unavailable

Is this realy an intentional behaviour? If so, I could not understand
for what the behaviour is...

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin-patches mailing list