Bug #72864 [Fbk->NoF]: FIFOs block only once

From: Date: Sun, 04 Jul 2021 04:22:13 +0000
Subject: Bug #72864 [Fbk->NoF]: FIFOs block only once
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234795@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 Updated by: php-bugs@lists.php.net Reported by: ryosuke_i_628 at yahoo dot co dot jp Summary: FIFOs block only once -Status: Feedback +Status: No Feedback Type: Bug Package: Streams related Operating System: OSX 10.11.5 PHP Version: 7.0.9 Assigned To: cmb Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. 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 (#234795) next »