FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

clearBuffer · BestByte/framework@d0ad658 · GitHub

Repository navigation

Commit d0ad658

Browse files
committed
clearBuffer
1 parent aa620c4 commit d0ad658

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎libs/Swoole/Protocol/HttpServer.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ function onConnect($serv, $client_id, $from_id)
7575
function onClose($serv, $client_id, $from_id)
7676
{
7777
$this->log("client[#$client_id@$from_id] close");
78-
unset($this->requests[$client_id], $this->buffer_header[$client_id]);
78+
$this->cleanBuffer($client_id);
79+
}
80+
81+
function cleanBuffer($fd)
82+
{
83+
unset($this->requests[$fd], $this->buffer_header[$fd]);
7984
}
8085

8186
function checkHeader($client_id, $http_data)

‎libs/Swoole/Protocol/WebSocket.php‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ function onClose($serv, $client_id, $from_id)
517517
{
518518
$this->onExit($client_id);
519519
$this->log("close client_id = $client_id");
520-
unset($this->ws_list[$client_id], $this->connections[$client_id], $this->requests[$client_id]);
520+
$this->cleanBuffer($client_id);
521521
parent::onClose($serv, $client_id, $from_id);
522522
}
523523

@@ -535,7 +535,17 @@ public function close($fd, $code = self::CLOSE_NORMAL, $reason = '')
535535
{
536536
$this->send($fd, pack('n', $code).$reason, self::OPCODE_CONNECTION_CLOSE);
537537
$this->log("server close connection[$fd]. reason: $reason, close_code = $code");
538-
unset($this->ws_list[$fd], $this->connections[$fd], $this->requests[$fd], $this->buffer_header[$fd]);
538+
$this->cleanBuffer($fd);
539539
return $this->server->close($fd);
540540
}
541+
542+
/**
543+
* 清理连接缓存区
544+
* @param $fd
545+
*/
546+
function cleanBuffer($fd)
547+
{
548+
parent::cleanBuffer($fd);
549+
unset($this->ws_list[$fd], $this->connections[$fd]);
550+
}
541551
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL