Browse Source

compatible with hhvm

walkor 9 years ago
parent
commit
dffe18c9a3
2 changed files with 8 additions and 2 deletions
  1. 4 1
      Connection/AsyncTcpConnection.php
  2. 4 1
      Connection/TcpConnection.php

+ 4 - 1
Connection/AsyncTcpConnection.php

@@ -217,7 +217,10 @@ class AsyncTcpConnection extends TcpConnection
             Worker::$globalEvent->del($socket, EventInterface::EV_WRITE);
             // Nonblocking.
             stream_set_blocking($socket, 0);
-            stream_set_read_buffer($socket, 0);
+            // Compatible with hhvm
+            if (function_exists('stream_set_read_buffer')) {
+                stream_set_read_buffer($socket, 0);
+            }
             // Try to open keepalive for tcp and disable Nagle algorithm.
             if (function_exists('socket_import_stream') && $this->transport === 'tcp') {
                 $raw_socket = socket_import_stream($socket);

+ 4 - 1
Connection/TcpConnection.php

@@ -218,7 +218,10 @@ class TcpConnection extends ConnectionInterface
         $this->id      = $this->_id = self::$_idRecorder++;
         $this->_socket = $socket;
         stream_set_blocking($this->_socket, 0);
-        stream_set_read_buffer($this->_socket, 0);
+        // Compatible with hhvm
+        if (function_exists('stream_set_read_buffer')) {
+            stream_set_read_buffer($this->_socket, 0);
+        }
         Worker::$globalEvent->add($this->_socket, EventInterface::EV_READ, array($this, 'baseRead'));
         $this->maxSendBufferSize = self::$defaultMaxSendBufferSize;
         $this->_remoteAddress    = $remote_address;