4

Swoole v4.6.3 版本发布,祝大家 2021 春节快乐

 3 years ago
source link: https://segmentfault.com/a/1190000039200539
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Swoole v4.6.3 版本发布,祝大家 2021 春节快乐

发布于 2 月 9 日

牛年春节在即,Swoole 也迎来了 2020年(农历)的最后一个版本。

在此感谢为 Swoole 的代码、文档以及生态方面做出贡献的小伙伴,也期待有更多的小伙伴加入\~

祝大家 2021 牛年春节快乐,Bug 全走开。

v4.6.3 版本主要是一个 Bug 修复版本,没有向下不兼容改动。

  • 新增了 Swoole\Coroutine\goSwoole\Coroutine\defer 函数,这个操作主要防止用户手动关闭了短名,去复制粘贴运行示例代码时会报错的问题
use function Swoole\Coroutine\go;
use function Swoole\Coroutine\run;
use function Swoole\Coroutine\defer;

run(function () {
    defer(function () {
        echo "co1 end\n";
    });
    sleep(1);
    go(function () {
        usleep(100000);
        defer(function () {
            echo "co2 end\n";
        });
        echo "co2\n";
    });
    echo "co1\n";
});
  • 如果用户知道 Content-Length 的长度,在此版本中也允许用户自行设置 Content-Length 的 HTTP 头。
    用户设置的 Content-Length HTTP 头会覆盖底层计算的 Content-Length
use Swoole\Http\Server;
use Swoole\Http\Request;
use Swoole\Http\Response;

$http = new Server('0.0.0.0', 9501);

$http->on('Request', function (Request $request, Response $response) {
    $msg = 'Hello, Swoole';
    $response->header('Content-Length', strlen($msg));
    $response->end($msg);
});

$http->start();

下面是完整的更新日志:

新增 API

  • 新增 Swoole\Coroutine\go 函数 (swoole/library@82f63be) (@matyhtf)
  • 新增 Swoole\Coroutine\defer 函数 (swoole/library@92fd0de) (@matyhtf)
  • 为 HTTP 服务器添加 compression\_min\_length 选项 (#4033) (@matyhtf)
  • 允许在应用层设置 Content-Length HTTP 头 (#4041) (@doubaokun)
  • 修复程序达到文件打开限制时的 coredump (swoole/swoole-src@709813f) (@matyhtf)
  • 修复 JIT 被禁用问题 (#4029) (@twose)
  • 修复 Response::create() 参数错误问题 (swoole/swoole-src@a630b5b) (@matyhtf)
  • 修复 ARM 平台下投递 task 时 task\_worker\_id 误报 (#4040) (@doubaokun)
  • 修复 PHP8 开启 native curl hook 时的 coredump (#4042)(#4045) (@Yurunsoft) (@matyhtf)
  • 修复 fatal error 时 shutdown 阶段的内存越界错误 (#4050) (@matyhtf)
  • 优化 ssl\_connect/ssl\_shutdown (#4030) (@matyhtf)
  • 发生 fatal error 时直接退出进程 (#4053) (@matyhtf)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK