Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86979 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16529 invoked from network); 30 Jun 2015 22:55:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jun 2015 22:55:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.18 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.18 mout.gmx.net Received: from [212.227.15.18] ([212.227.15.18:53595] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B2/10-06060-D4E13955 for ; Tue, 30 Jun 2015 18:55:10 -0400 Received: from [192.168.0.100] ([95.89.139.132]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0Lrviw-1Z4FMj07SA-013e0W; Wed, 01 Jul 2015 00:54:59 +0200 Message-ID: <55931E47.6030209@gmx.de> Date: Wed, 01 Jul 2015 00:55:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Anatol Belski , 'PHP Internals' CC: 'Pierre Joye' , 'Kalle Sommer Nielsen' , 'Dmitry Stogov' , 'Xinchen Hui' , 'Nikita Popov' References: <055b01d0b364$5414b890$fc3e29b0$@belski.net> In-Reply-To: <055b01d0b364$5414b890$fc3e29b0$@belski.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:p1zCr0PIA64OVQFOsAJanbTziYa5YU8B47rlVTKV4m+Xfeavq1W 2WZQqcpW1/q0qkRm9dZMCAQYzfwRFblUJA4KE6dIEelwGrpI+h8Z28OqNaoq6/XtLfKR1qQ 9K95RxtyLzqz4ORzFE+EWkfrbJ9EDZto3ioVOWq2pg+udqdg3K4j0V632FH/Qcp3zyFfvtN W9P28M9/EgWNewoeo6xJw== X-UI-Out-Filterresults: notjunk:1;V01:K0:HhVmALKF37o=:aw2e5T3gzqIhjhJLEETGiN eW3YCRL/43u5woox427GfM2CrhHw7HMRshWHf4nMyVxcy+saJYKbbohlBDO2xn0Ptq4NDt29E /enOo38LYiFm6LljUtNV2L6IzYPojI1I47ujUL1AYrmIvT5ApCig/sI23GIKM6LH0Ma19R+s2 23YXHD3R8xoINQsu5yImrECDHikC75R4ViYX+u/PDLjcmREi7iC/BtH9Qt/0FyUPOVAmZS0ZT A2Q2GKqgBoW73fHrSCSTC1f+BggtxwFdgjZ3hMeK3baij7/9HQAShRuq+OD+7y9tRv9QHaW8j d6PKkHuxiER5s7mPEZuDf/h0L7DPLI970cQNFR8moF0OmCTnrW+SLLV7oLRRGAA/HDEX/IlPd jfY5FRbJenFKJUmT5BqQQDhqmQf3/6LRbU/W/y72qhzBlftBmXP62/0BfTahN01if2nYKxgQM oNrMljwPcI8Khx8fvBudQfTAWP9yWwByP//4iwn72aKpqHL/DGU1IH2NqoiBm+JGD65E3Qy/1 /jkQODKtAvoZKW5HYc1X1Q7Rvf2JnQ9irPQ6+8v2oPKdTVHnojO3rycRp2hmDHjHT0gLk8Qay GGB5/BaBUirF+t703AK2f7tQJZAgcyfZOkQrBqovyTZRCx4T+wmi9R6rvtpDsFLZJGMyE9jQT 6tsqp+5n8LWqLV0lQ8Hswe8yY6jd7fcmKsW1t7sqxVMPPDMEhr89v8u6/87JDn2/hC+4= Subject: Re: Fixes for #69900 and #69963 From: cmbecker69@gmx.de (Christoph Becker) Hi! Anatol Belski wrote: > regarding the mentioned tickets I've prepared a patch > https://github.com/php/php-src/compare/master...weltling:pipe_blocking_win . Great. > Anonymous pipes on Windows > > - don't support asynchronous IO > - don't support select() > - have buffer size of 4096 bytes (or even less) which is much easier > overflown that a buffer of 64kb often to be seen on Unix It appears to be possible to set the buffer size by passing a nSize argument > 0 to CreatePipe[1][2]. Maybe it's reasonable to use 16 or 64 kB by default? > These issues was addressed last year, but the tickets mentioned report about > the issues still persisting in PHP5/7. While it's likely a no go for PHP5, I > would like to push this patch into PHP7. Particularly what it does is > allowing the blocking read() again for the edge cases reported in the listed > tickets. It is done adding a context option and a new win only option for > proc_open. Just to illustrate a few - > > ==== SNIPPET ==== > /* here proc_open() will do a blocking read on the child process*/ > $process = proc_open(PHP_BINARY.' -f ' . $fl, $descriptorspec, $pipes, NULL, > NULL, array("blocking_pipes" => true)); > ==== END SNIPPET ==== > > ==== SNIPPET ==== > $in = fopen("php://stdin", "rb", false, stream_context_create(array("pipe" > => array("blocking" => true)))); > +while(!feof($in)){ /* here feof() will do a blocking read on the pipe */ > ......................... > ==== END SNIPPET ==== > > The only drawback on this is that blocking reads on pipes are likely to > cause pipe buffer overflows and thus deadlock, like it was before. Though, > when working with them carefully, this could be avoided and would bring > improvements with several edge cases, almost when working on CLI. Anyway > this patch brings no difference to PHP5 while addressing those edge cases. > > I would like to ask for review here. I've also made a minimal build with > this patch http://windows.php.net/downloads/snaps/ostc/69900/ for those > interested to test. If there are no strong objections, it should be merged > soon. I did some quick tests and the patch works fine. However, proc_open_bug69900.phpt fails on my machine (Win 7), because 0ms are reported for all but the first read (microtime issue on older Windows'). Maybe it's better to EXPECT something like "took less than 1 ms"? I have noticed that you've changed the bitfields of struct php_stdio_stream_data (in plain_wrapper.c). Wouldn't it be better to do: - unsigned is_pipe_blocking; + unsigned is_pipe_blocking:1; + unsigned _reserved:28; [1] [2] -- Christoph M. Becker