Bug #72864 [Com]: FIFOs block only once

From: Date: Fri, 25 Jun 2021 04:50:12 +0000
Subject: Bug #72864 [Com]: FIFOs block only once
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234627@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72864&edit=1 ID: 72864 Comment by: vefaconkokev at getnada dot com Reported by: ryosuke_i_628 at yahoo dot co dot jp Summary: FIFOs block only once Status: Feedback Type: Bug Package: Streams related Operating System: OSX 10.11.5 PHP Version: 7.0.9 Assigned To: cmb Block user comment: N Private report: N New Comment: Dressbarn Feedback Survey will accept all your feedback and reviews and will use it to improve customer service, store atmosphere, and product standards, where suitable. https://takesurveyz.onl/www-dressbarnfeedback-com/ Previous Comments: ------------------------------------------------------------------------ [2021-06-22 13:54:37] cmb@php.net This is not related to cURL at all; the same behavior can be observed with the following script: <?php $fp = fopen("/path/to/fifo", 'rb'); var_dump(fread($fp,1)); var_dump(fread($fp,1)); ?> As far as I know, that is norrmal behavior of fifos[1]: | The FIFO must be opened on both ends (reading and writing) | before data can be passed. Normally, opening the FIFO blocks | until the other end is opened also. [1] <https://man7.org/linux/man-pages/man7/fifo.7.html> ------------------------------------------------------------------------ [2016-08-17 10:22:49] ryosuke_i_628 at yahoo dot co dot jp Note that: - cURL actually sends "Content-Length: 5" - Additional printf calls after the first call are completely ignored ------------------------------------------------------------------------ [2016-08-17 10:14:08] ryosuke_i_628 at yahoo dot co dot jp Description: ------------ CURLOPT_READFUNCTION waits $fp readable only once. Is this a bug? Or by design? Test script: --------------- <?php /* mkfifo /path/to/fifo */ $fp = fopen('/path/to/fifo', 'rb'); $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => 'example.com', CURLOPT_PUT => true, CURLOPT_INFILE => $fp, CURLOPT_INFILESIZE => 5, CURLOPT_READFUNCTION => function ($ch, $fp, $max) { $buf = fread($fp, 1); var_dump($buf); return $buf; }, ]); curl_exec($ch); /* We can verify that CURLOPT_READFUNCTION invocation is blocked. However, after we executed the following command... printf "a" > /path/to/fifo */ ?> Expected result: ---------------- string(1) "a" ...then invocation should be blocked again Actual result: -------------- string(1) "a" string(0) "" ...wtf!? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72864&edit=1

« previous php.bugs (#234627) next »