正在显示
1 个修改的文件
包含
7 行增加
和
4 行删除
@@ -51,18 +51,20 @@ class ProxyService | @@ -51,18 +51,20 @@ class ProxyService | ||
51 | if(empty($this->clients[$fd])){ | 51 | if(empty($this->clients[$fd])){ |
52 | $this->clients[$fd] = new SmtpClient(); | 52 | $this->clients[$fd] = new SmtpClient(); |
53 | } | 53 | } |
54 | + | ||
55 | + $client = $this->clients[$fd]; | ||
54 | // 加锁 | 56 | // 加锁 |
55 | - $this->clients[$fd]->lock(); | 57 | + $client->lock(); |
56 | // 处理数据 | 58 | // 处理数据 |
57 | - $result = $this->clients[$fd]->exec($data); | 59 | + $result = $client->exec($data); |
58 | // 解锁 | 60 | // 解锁 |
59 | - $this->clients[$fd]->unlock(); | 61 | + $client->unlock(); |
60 | // 返回结果 | 62 | // 返回结果 |
61 | $server->send($fd, $this->push($result[1])); | 63 | $server->send($fd, $this->push($result[1])); |
62 | // 是否关闭连接 | 64 | // 是否关闭连接 |
63 | if($result[0]===false){ | 65 | if($result[0]===false){ |
64 | // 关闭并释放资源 | 66 | // 关闭并释放资源 |
65 | - $this->clients[$fd]->close(); | 67 | + $client->close(); |
66 | $this->clients[$fd] = null; | 68 | $this->clients[$fd] = null; |
67 | unset($this->clients[$fd]); | 69 | unset($this->clients[$fd]); |
68 | 70 | ||
@@ -73,6 +75,7 @@ class ProxyService | @@ -73,6 +75,7 @@ class ProxyService | ||
73 | //监听连接关闭事件。 | 75 | //监听连接关闭事件。 |
74 | $server->on('Close', function ($server, $fd) { | 76 | $server->on('Close', function ($server, $fd) { |
75 | echo '连接关闭了 => '.$fd."\n"; | 77 | echo '连接关闭了 => '.$fd."\n"; |
78 | + $this->clients[$fd] = null; | ||
76 | unset($this->clients[$fd]); | 79 | unset($this->clients[$fd]); |
77 | }); | 80 | }); |
78 | 81 |
-
请 注册 或 登录 后发表评论