You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
42
vendor/swoole/tests/include/api/swoole_callback/swoole_cannot_destroy_active_lambda_function.php
vendored
Executable file
42
vendor/swoole/tests/include/api/swoole_callback/swoole_cannot_destroy_active_lambda_function.php
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// Cannot destroy active lambda swoole_function
|
||||
// 先用nc起一个 swoole_server
|
||||
// nc -4lk 9090
|
||||
|
||||
send("hello", function($cli, $data) {
|
||||
var_dump($data);
|
||||
send("hello", function($cli, $data) {
|
||||
var_dump($data);
|
||||
send("hello", function($cli, $data) {
|
||||
var_dump($data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function send($str, $onRecv)
|
||||
{
|
||||
static $client;
|
||||
|
||||
if ($client === null) {
|
||||
$client = new \swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
|
||||
|
||||
$client->on("error", function($cli) { echo "error"; });
|
||||
$client->on("close", function($cli) { echo "close"; });
|
||||
|
||||
$client->on("connect", function($cli) use($str, $onRecv) {
|
||||
send($str, $onRecv);
|
||||
});
|
||||
}
|
||||
|
||||
// !!! Fatal error: Cannot destroy active lambda swoole_function
|
||||
$client->on("receive", $onRecv);
|
||||
|
||||
if ($client->isConnected()) {
|
||||
$client->send("PING");
|
||||
} else {
|
||||
$client->connect("127.0.0.1", 9090);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user