Doc #62723 [Nab]: stream_select returns when there is output, not when state changes

From: Date: Thu, 15 Nov 2012 16:47:06 +0000
Subject: Doc #62723 [Nab]: stream_select returns when there is output, not when state changes
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9158@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62723&edit=1

 ID:                 62723
 User updated by:    thuejk at gmail dot com
 Reported by:        thuejk at gmail dot com
 Summary:            stream_select returns when there is output, not when
                     state changes
 Status:             Not a bug
 Type:               Documentation Problem
 Package:            Streams related
 Operating System:   Linux
 PHP Version:        5.3.15
 Block user comment: N
 Private report:     N

 New Comment:

I have the impression that you did not read my bug report. Your reply does not 
make sense to me. I do say that the current behavior is expected. What I also say 
is that the documentation disagrees.

This bug should be reopened.


Previous Comments:
------------------------------------------------------------------------
[2012-11-15 12:11:24] krakjoe@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

This is expected, you are not working with sockets but streams, it is correct that 
a stream should consider it's buffers to be indicative of state.

------------------------------------------------------------------------
[2012-08-02 09:23:00] thuejk at gmail dot com

Description:
------------
The documentation for stream_select() says ( 
http://www.php.net/manual/en/function.stream-select.php
)

"The stream_select() function accepts arrays of streams and waits for them to 
change status."

But that is not true. stream_select will return immediately if the read buffer of 
a stream is non-empty. The read buffer does not have to change status or length 
for stream_select() to return.

Obviously the current behaviour of stream_select() is correct, and the 
documentation is wrong. The current behaviour is also how select() (which the 
documentation says stream_select behaves like) works.

Test script:
---------------
<?php

function my_passthru2() {
  $cmd = sprintf("echo a;sleep 100000");
  $stream = popen($cmd, "r");
  $stream_array = Array($stream);
  $dummy_array = null;
  sleep(1);
  echo "after sleep";
  stream_select($stream_array, $dummy_array, $dummy_array, 10);
  echo "after select!";
}

my_passthru2();

?>

Expected result:
----------------
Following the documentation: "after select!" should be printed 10 seconds after 
"after sleep", since the stream does not change status after stream_select is 
called (the read buffer will always contain "a").

Actual result:
--------------
"after select!" is printed immediately after "after sleep".


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62723&edit=1


Thread (3 messages)

« previous php.doc.bugs (#9158) next »