Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86976 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70307 invoked from network); 30 Jun 2015 18:41:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jun 2015 18:41:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=anatol.php@belski.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=anatol.php@belski.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain belski.net from 85.214.73.107 cause and error) X-PHP-List-Original-Sender: anatol.php@belski.net X-Host-Fingerprint: 85.214.73.107 klapt.com Received: from [85.214.73.107] ([85.214.73.107:44617] helo=h1123647.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/21-46577-5C2E2955 for ; Tue, 30 Jun 2015 14:41:10 -0400 Received: by h1123647.serverkompetenz.net (Postfix, from userid 1006) id 5BBE56D2038; Tue, 30 Jun 2015 20:41:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on h1123647.serverkompetenz.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.5 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable version=3.3.2 Received: from w530phpdev (pD9FE89DC.dip0.t-ipconnect.de [217.254.137.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by h1123647.serverkompetenz.net (Postfix) with ESMTPSA id 792C223D615B; Tue, 30 Jun 2015 20:41:04 +0200 (CEST) To: "'PHP Internals'" Cc: "'Pierre Joye'" , "'Kalle Sommer Nielsen'" , "'Dmitry Stogov'" , "'Xinchen Hui'" , "'Nikita Popov'" Date: Tue, 30 Jun 2015 20:41:04 +0200 Message-ID: <055b01d0b364$5414b890$fc3e29b0$@belski.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AdCzYMOSN3GU+SsaRUKZzo8psI4Tig== Content-Language: en-us Subject: Fixes for #69900 and #69963 From: anatol.php@belski.net ("Anatol Belski") Hi, regarding the mentioned tickets I've prepared a patch https://github.com/php/php-src/compare/master...weltling:pipe_blocking_win . 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 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. Thanks Anatol