Fixed context won't be destroyed when accept keepalive connection for co server. (#2227)

This commit is contained in:
李铭昕 2020-08-01 11:47:33 +08:00 committed by GitHub
parent bbaffc409c
commit dd1ff1164a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@
- [#2210](https://github.com/hyperf/hyperf/pull/2210) Fixed bug that open event won't be executed after handshake right now.
- [#2214](https://github.com/hyperf/hyperf/pull/2214) Fixed bug that close event won't be executed when close the connection by websocket server.
- [#2218](https://github.com/hyperf/hyperf/pull/2218) Fixed bug that sender does not works for coroutine server.
- [#2227](https://github.com/hyperf/hyperf/pull/2227) Fixed context won't be destroyed when accept keepalive connection for co server.
## Optimized

View File

@ -145,7 +145,11 @@ class CoroutineServer implements ServerInterface
$handler->initCoreMiddleware($name);
}
if ($this->server instanceof \Swoole\Coroutine\Http\Server) {
$this->server->handle('/', [$handler, $method]);
$this->server->handle('/', static function ($request, $response) use ($handler, $method) {
Coroutine::create(static function () use ($request, $response, $handler, $method) {
$handler->{$method}($request, $response);
});
});
}
}
return;