Pārlūkot izejas kodu

Merge pull request #870 from landso/master

Fix connection closed before file send completed
walkor 2 gadi atpakaļ
vecāks
revīzija
303d7f206e
2 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 3 0
      src/Connection/TcpConnection.php
  2. 2 0
      src/Protocols/Http.php

+ 3 - 0
src/Connection/TcpConnection.php

@@ -723,6 +723,9 @@ class TcpConnection extends ConnectionInterface implements \JsonSerializable
                 }
             }
             if ($this->_status === self::STATUS_CLOSING) {
+                if ($this->__streamSending) {
+                    return true;
+                }
                 $this->destroy();
             }
             return true;

+ 2 - 0
src/Protocols/Http.php

@@ -249,6 +249,7 @@ class Http
     protected static function sendStream(TcpConnection $connection, $handler, $offset = 0, $length = 0)
     {
         $connection->bufferFull = false;
+        $connection->__streamSending = true;
         if ($offset !== 0) {
             \fseek($handler, $offset);
         }
@@ -275,6 +276,7 @@ class Http
                 if ($buffer === '' || $buffer === false) {
                     fclose($handler);
                     $connection->onBufferDrain = null;
+                    $connection->__streamSending = false;
                     return;
                 }
                 $connection->send($buffer, true);