Skip to content

Commit 144bbe2

Browse files
authored
Fixed bug that db connection couldn't be released to pool when using coroutine style websocket server. (#3467)
1 parent d1853af commit 144bbe2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Server.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,15 @@ public function onHandShake(SwooleRequest $request, SwooleResponse $response): v
207207
while (true) {
208208
$frame = $response->recv();
209209
if ($frame === false || $frame instanceof CloseFrame || $frame === '') {
210-
$onCloseCallbackInstance->{$onCloseCallbackMethod}($response, $fd, 0);
210+
wait(static function () use ($onCloseCallbackInstance, $onCloseCallbackMethod, $response, $fd) {
211+
$onCloseCallbackInstance->{$onCloseCallbackMethod}($response, $fd, 0);
212+
});
211213
break;
212214
}
213-
$onMessageCallbackInstance->{$onMessageCallbackMethod}($response, $frame);
215+
216+
wait(static function () use ($onMessageCallbackInstance, $onMessageCallbackMethod, $response, $frame) {
217+
$onMessageCallbackInstance->{$onMessageCallbackMethod}($response, $frame);
218+
});
214219
}
215220
} else {
216221
$this->deferOnOpen($request, $class, $server);

0 commit comments

Comments
 (0)