Giter Site home page Giter Site logo

Comments (2)

nielsdos avatar nielsdos commented on May 31, 2024 1

stream_select modifies the array passed as an argument.

See https://www.php.net/manual/en/function.stream-select which says:

Note:

When stream_select() returns, the arrays read, write and except are modified to indicate which stream resource(s) actually changed status. The original keys of the arrays are preserved.

You can observe this by adding a var_dump inside your while loop.
The first iteration works, but the second one has cleared out the arrays, so the second call to stream_select fails because the arrays are empty.
If you change the last while loop to this, it seems to work:

while(!stream_select($read, $read, $read, 0)) {
    var_dump($read, count($read));
    $read = [$server];
    usleep(1000);
}

So as far as I can tell, this issue is about a misunderstanding of how stream_select works. Does this help you, or am I missing something?

from php-src.

R3kyr avatar R3kyr commented on May 31, 2024 1

Oh my god, I've been so blind... Yes, you're absolutely right! I should've checked the docs more precisely... So it was a simple race condtion all the time. Sorry for this unnecessary ticket.

from php-src.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.