Skip to content

Commit

Permalink
workaround for stream_socket_accept() bug. refs #26
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph authored and indeyets committed Aug 23, 2012
1 parent 4a43d02 commit fd60459
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion AiP/Transport/Socket.php
Expand Up @@ -15,9 +15,21 @@ class Socket extends AbstractTransport
public function loop()
{
$this->in_loop = true;

while ($this->in_loop) {
$conn = false;

$read = array($this->socket);
$write = null;
$except = null;

declare(ticks=1) {
$conn = @stream_socket_accept($this->socket, -1);
// stream_socket_accept() doesn't block on some(?) of the ARM systems
// so, wrapping it into stream_select() which works always
// see https://bugs.php.net/bug.php?id=62816
if (1 === stream_select($read, $write, $except, null)) {
$conn = @stream_socket_accept($this->socket, 0);
}
}

if (false === $conn)
Expand Down

0 comments on commit fd60459

Please sign in to comment.