Skip to content

Releases: swoole/swoole-src

v5.1.4

23 Aug 02:33
d14d6a2
Compare
Choose a tag to compare

🐛 Bug Fixed:

  • Fix broken build with GCC 14. @remicollet
  • Fix could not send SSL negotiation packet(Resource temporarily unavailable). @NathanFreeman
  • Fix the issue where certain critical parameters of Swoole\Server are not reset to 0 during process restart. @NathanFreeman
  • Fix the problem where Swoole\Http\Request::getMethod() returns the incorrect request method when HTTP2 is enabled. @matyhtf

💪 Optimization:

  • Optimize Swoole\Http\Response::end(). Response data larger than 16K will be sent directly through the socket, while data smaller than or equal to 16K will be copied to the buffer first before being sent out via the socket. @NathanFreeman

😊 Thank you

  • Thank you for your contribution to Swoole v5.1.4. Wish you good health, all the best, and smooth work.

🐛 Bug 修复:

  • 修复无法在GCC 14编译Swoole的问题。 @remicollet
  • 修复pdo_pgsql在协程化时会抛出资源不可用的错误。 @NathanFreeman
  • 修复Swoole\Server进程重启时,某些关键参数不会重置为0。 @NathanFreeman
  • 修复开启HTTP2时,Swoole\Http\Request::getMethod()返回错误的请求方法的问题。 @matyhtf

💪 优化:

  • 优化Swoole\Http\Response::end(),大于16K的响应数据将通过套接字直接发送,小于等于16K的数据会先拷贝在buffer中,再通过套接字发送出去。 @NathanFreeman

😊 致谢

  • 感谢你们为Swoole v5.1.4做出的贡献,祝愿大家身体健康,万事如意,工作顺利。

v6.0.0-alpha

24 Jun 02:44
Compare
Choose a tag to compare
v6.0.0-alpha Pre-release
Pre-release

✨ New Feature:

  • Swoole supports multi-threading mode. When PHP is in ZTS mode and Swoole is compiled with --enable-swoole-thread, the multi-threading mode can be utilized.
  • Added a new thread management class Swoole\Thread. @matyhtf
  • Introduced thread lock Swoole\Thread\Lock. @matyhtf
  • Added thread atomic counter Swoole\Thread\Atomic, Swoole\Thread\Atomic\Long. @matyhtf
  • Added safe concurrent containers Swoole\Thread\Map, Swoole\Thread\ArrayList, Swoole\Thread\Queue. @matyhtf
  • File asynchronous operations support iouring as the underlying engine. Installing liburing and compiling Swoole with --enable-iouring enables asynchronous operations for functions like file_get_contents, file_put_contents, fopen, fclose, fread, fwrite, mkdir, unlink, fsync, fdatasync, rename, fstat, lstat, filesize through iouring. @matyhtf @NathanFreeman
  • Upgraded Boost Context to version 1.84. Now, Loongson CPUs can also support coroutines. @NathanFreeman

📖 example:

  • How to create threads
use Swoole\Thread;

$args = Thread::getArguments(); // If it is main thread, the $args is empty; if it is a child thread, the $args is not empty.
$c = 4;

if (empty($args)) {
    # main thread
    for ($i = 0; $i < $c; $i++) {
        $threads[] = new Thread(__FILE__, $i);
    }
    for ($i = 0; $i < $c; $i++) {
        $threads[$i]->join();
    }
} else {
    # child thread x 4
    echo "Thread #" . $args[0] . "\n";
    while (1) {
        sleep(1);
        file_get_contents('https://www.baidu.com/');
    }
}
  • Thread + Server (Asynchronous Style)
use Swoole\Process;
use Swoole\Thread;
use Swoole\Http\Server;

$http = new Server("0.0.0.0", 9503, SWOOLE_THREAD);
$http->set([
    'worker_num' => 2,
    'task_worker_num' => 3,
    'bootstrap' => __FILE__,
    // sharing data between threads through `init_arguments`.
    'init_arguments' => function () use ($http) {
        $map = new Swoole\Thread\Map;
        return [$map];
    }
]);

$http->on('Request', function ($req, $resp) use ($http) {
    $resp->end('hello world');
});

$http->on('pipeMessage', function ($http, $srcWorkerId, $msg) {
    echo "[worker#" . $http->getWorkerId() . "]\treceived pipe message[$msg] from " . $srcWorkerId . "\n";
});

$http->addProcess(new Process(function () {
   echo "user process, id=" . Thread::getId();
   sleep(2000);
}));

$http->on('Task', function ($server, $taskId, $srcWorkerId, $data) {
    var_dump($taskId, $srcWorkerId, $data);
    return ['result' => uniqid()];
});

$http->on('Finish', function ($server, $taskId, $data) {
    var_dump($taskId, $data);
});

$http->on('WorkerStart', function ($serv, $wid) {
    // Retrieve shared data passed by `init_arguments` in the configuration using `Swoole\Thread::getArguments()`.
    var_dump(Thread::getArguments(), $wid);
});

$http->on('WorkerStop', function ($serv, $wid) {
    var_dump('stop: T' . Thread::getId());
});

$http->start();
  • Thread + Coroutine
use Swoole\Thread;

$args = Thread::getArguments(); // If it is main thread, the $args is empty; if it is a child thread, the $args is not empty.
$c = 4;

if (empty($args)) {
    # main thread
    for ($i = 0; $i < $c; $i++) {
        $threads[] = new Thread(__FILE__, $i);
    }
    for ($i = 0; $i < $c; $i++) {
        $threads[$i]->join();
    }
} else {
    # child thread x 4
    echo "Thread #" . $args[0] . "\n";
    Co\run(function() {
       while (1) {
          sleep(1);
          Co\go(function () {
              file_get_contents('https://www.baidu.com/');
          });
      }
    });
}

🐛 Bug Fixed:

  • Fixed the issue where installation via pecl was not possible. @remicollet
  • Fixed the bug where setting keepalive was not possible for Swoole\Coroutine\FastCGI\Client. @NathanFreeman
  • Fixed the issue where exceeding the max_input_vars would throw an error, causing the process to restart repeatedly. @NathanFreeman
  • Fixed unknown issues caused by using Swoole\Event::wait() within a coroutine. @matyhtf
  • Fixed the problem where proc_open does not support pty in coroutine mode. @matyhtf
  • Fixed segmentation fault issues with pdo_sqlite on PHP 8.3. @NathanFreeman
  • Fixed unnecessary warnings during the compilation of Swoole. @Appla @NathanFreeward
  • Fixed the error thrown by zend_fetch_resource2_ex when STDOUT/STDERR are already closed. @Appla @matyhtf
  • Fixed ineffective set_tcp_nodelay configuration. @matyhtf
  • Fixed the occasional unreachable branch issue during file upload. @NathanFreeman
  • Fixed the problem where setting dispatch_func would cause PHP's internals to throw errors. @NathanFreeman
  • Fixed the deprecation of AC_PROG_CC_C99 in autoconf >= 2.70. @petk
  • Capture exceptions when thread creation fails. @matyhtf
  • Fixed the undefined problem with _tsrm_ls_cache. @jingjingxyk
  • Fixed the fatal compile error with GCC 14. @remicollet

⭐️ Kernel optimization:

  • Removed unnecessary checks for socket structs. @petk
  • Upgraded Swoole Library. @deminy
  • Added support for status code 451 in Swoole\Http\Response. @abnegate
  • Synchronized file operation code across different PHP versions. @NathanFreeman
  • Synchronized pdo operation code across different PHP versions. @NathanFreeman
  • Optimized the code for Socket::ssl_recv(). @matyhtf
  • Improved config.m4; some configurations can now set library locations via pkg-config. @NathanFreeman
  • Optimized the use of dynamic arrays during request header parsing. @NathanFreeman
  • Optimized file descriptor fd lifecycle issues in multi-threading mode. @matyhtf
  • Optimized some fundamental coroutine logic. @matyhtf

❌ Deprecated:

  • No longer supports PHP 8.0.
  • No longer supports Swoole\Coroutine\MySQL coroutine client.
  • No longer supports Swoole\Coroutine\Redis coroutine client.
  • No longer supports Swoole\Coroutine\PostgreSQL coroutine client.

⚠ Warning:

  • Swoole-v6.0.0-alpha is a test version and cannot be used in any production environment; it is for testing purposes only.

😊 Thank you

  • Thank you for your contribution to Swoole v6.0.0. Wish you good health, all the best, and smooth work.

✨ 新特性:

  • Swoole支持多线程模式,当phpzts模式,编译Swoole时开启--enable-swoole-thread时,就能使用多线程模式。
  • 新增线程管理类Swoole\Thread@matyhtf
  • 新增线程锁Swoole\Thread\Lock@matyhtf
  • 新增线程原子计数Swoole\Thread\AtomicSwoole\Thread\Atomic\Long@matyhtf
  • 新增安全并发容器Swoole\Thread\MapSwoole\Thread\ArrayListSwoole\Thread\Queue@matyhtf
  • 文件异步操作支持iouring作为底层引擎,安装了liburing和编译Swoole时开启--enable-iouringfile_get_contentsfile_put_contentsfopenfclosefreadfwritemkdirunlinkfsyncfdatasyncrenamefstatlstatfilesize这些函数的异步操作将会由iouring实现。 @matyhtf @NathanFreeman
  • 升级Boost Context版本到1.84。现在,龙芯CPU也能够支持协程了。 @NathanFreeman

📖 示例:

  • 创建线程
use Swoole\Thread;

$args = Thread::getArguments(); // 如果是主线程,$args 为空,如果是子线程,$args 不为空
$c = 4;

if (empty($args)) {
    # 主线程
    for ($i = 0; $i < $c; $i++) {
        $threads[] = new Thread(__FILE__, $i);
    }
    for ($i = 0; $i < $c; $i++) {
        $threads[$i]->join();
    }
} else {
    # 子线程
    echo "Thread #" . $args[0] . "\n";
    while (1) {
        sleep(1);
        file_get_contents('https://www.baidu.com/');
    }
}
  • 线程 + 服务端(异步风格)
use Swoole\Process;
use Swoole\Thread;
use Swoole\Http\Server;

$http = new Server("0.0.0.0", 9503, SWOOLE_THREAD);
$http->set([
    'worker_num' => 2,
    'task_worker_num' => 3,
    'bootstrap' => __FILE__,
    // 通过init_arguments实现线程间的数据共享。
    'init_arguments' => function () use ($http) {
        $map = new Swoole\Thread\Map;
        return [$map];
    }
]);

$http->on('Request', function ($req, $resp) use ($http) {
    $resp->end('hello world');
});

$http->on('pipeMessage', function ($http, $srcWorkerId, $msg) {
    echo "[worker#" . $http->getWorkerId() . "]\treceived pipe message[$msg] from " . $srcWorkerId . "\n";
});

$http->addProcess(new Process(function () {
   echo "user process, id=" . Thread::getId();
   sleep(2000);
}));

$http->on('Task', function ($server, $taskId, $srcWorkerId, $data) {
    var_dump($taskId, $srcWorkerId, $data);
    return ['result' => uniqid()];
});

$http->on('Finish', function ($server, $taskId, $data) {
    var_dump($taskId, $data);
});

$http->on('WorkerStart', function ($serv, $wid) {
    // 通过Swoole\Thread::getArguments()获取配置中的init_arguments传递的共享数据
    var_dump(Thread::getArguments(), $wid);
});

$http->on('WorkerStop', function ($serv, $wid) {
    var_dump('stop: T' . Thread::getId());
});

$http->start();
  • Thread + Coroutine 在线程中使用协程
use Swoole\Thread;

$args = Thread::getArguments(); // If it is main thread, the $args is empty; if it is a child thread, the $args is not empty.
$c = 4;

if (empty($args)) {
    # main thread
    for ($i = 0; $i < $c; $i++) {
        $threads[] = new Thread(__FILE__, $i);
    }
    for ($i = 0; $i < $c; $i++) {
        $threads[$i]->join();
    }
} else {
    # child thread x 4
    echo "Thread #" . $args[0] . "\n";
    Co\run(function() {
       while (1) {
          sleep(1);
          Co\go(function () {
              file_get_contents('https://www.baidu.com/');
          });
      }
    });
}

🐛 Bug修复:

  • 修复无法通过pecl安装的问题。 @remicollet
  • 修复Swoole\Coroutine\FastCGI\Client客户端无法设置keepalive。 @NathanFreeman
  • 修复请求参数超过max_input_vars时会抛出错误导致进程不断重启的问题。 @NathanFreeman
  • 修复在协程中使用Swoole\Event::wait()导致的未知问题。 @matyhtf
  • 修复proc_open在协程化的时候不支持pty的问题。 @matyhtf
  • 修复pdo_sqlite在PHP8.3会出现段错误的问题。 @NathanFreeman
  • 修复编译Swoole时的无用警告。 @Appla @NathanFreeman
  • 修复如果STDOUT/STDERR已经关闭时,底层调用zend_fetch_resource2_ex会抛出错误。 @Appla @matyhtf
  • 修复无效的set_tcp_nodelay配置。 @matyhtf
  • 修复文件上传的时...
Read more

v5.1.3

06 Jun 07:31
8e8db8b
Compare
Choose a tag to compare

🐛 Bug Fixed:

  • Fix the problem of being unable to install through pecl. @remicollet
  • Fix the issue of Swoole\Coroutine\FastCGI\Client client being unable to set keepalive. @NathanFreeman
  • Fix the issue of process continuously restarting due to error thrown when request parameters exceed max_input_vars. @NathanFreeman
  • Fix the unknown issue caused by using Swoole\Event::wait() in a coroutine. @matyhtf
  • Fix the issue of proc_open not supporting pty when used in a coroutine. @matyhtf
  • Fix the segmentation fault issue in pdo_sqlite on PHP 8.3. @NathanFreeman
  • Fix the unnecessary warning when compiling Swoole. @Appla @NathanFreeman
  • Fix the error thrown when calling zend_fetch_resource2_ex on closed STDOUT/STDERR. @Appla @matyhtf
  • Fix the invalid set_tcp_nodelay configuration. @matyhtf
  • Fix the occasional unreachable branch issue triggered during file uploads. @NathanFreeman
  • Fix the issue causing PHP core to throw errors when dispatch_func is set. @NathanFreeman
  • Fix the obsolete warning of AC_PROG_CC_C99 in autoconf >= 2.70 version. @petk

⭐️ Kernel optimization:

  • Remove unnecessary checks for socket structs. @petk
  • Upgrade the Swoole library. @deminy
  • Add support for status code 451 in Swoole\Http\Response. @abnegate
  • Synchronize file operation code across different versions of PHP. @NathanFreeman
  • Synchronize PDO operation code across different versions of PHP. @NathanFreeman
  • Optimize the code for Socket::ssl_recv() function. @matyhtf
  • Optimized config.m4 by allowing some configurations to set dependency library locations using pkg-config. @NathanFreeman
  • Optimize the issue with using dynamic arrays when parsing request headers. @NathanFreeman

😊 Thank you

  • Thank you for your contribution to Swoole v5.1.3. Wish you good health, all the best, and smooth work.

🐛 Bug修复:

  • 修复无法通过pecl安装的问题。 @remicollet
  • 修复Swoole\Coroutine\FastCGI\Client客户端无法设置keepalive。 @NathanFreeman
  • 修复请求参数超过max_input_vars时会抛出错误导致进程不断重启的问题。 @NathanFreeman
  • 修复在协程中使用Swoole\Event::wait()导致的未知问题。 @matyhtf
  • 修复proc_open在协程化的时候不支持pty的问题。 @matyhtf
  • 修复pdo_sqlite在PHP8.3会出现段错误的问题。 @NathanFreeman
  • 修复编译Swoole时的无用警告。 @Appla @NathanFreeman
  • 修复如果STDOUT/STDERR已经关闭时,底层调用zend_fetch_resource2_ex会抛出错误。 @Appla @matyhtf
  • 修复无效的set_tcp_nodelay配置。 @matyhtf
  • 修复文件上传的时候偶尔会触发不可达的分支问题。 @NathanFreeman
  • 修复设置了dispatch_func,会导致php底层抛出错误的问题。 @NathanFreeman
  • 修复AC_PROG_CC_C99在autoconf >= 2.70版本中已过时。 @petk

⭐️ 内核优化:

  • 移除对socket structs的无用检查。 @petk
  • 升级swoole Library。 @deminy
  • Swoole\Http\Response增加对451状态码的支持。 @abnegate
  • 同步PHP不同版本的文件操作代码。 @NathanFreeman
  • 同步PHP不同版本的pdo操作代码。 @NathanFreeman
  • 优化Socket::ssl_recv()的代码。 @matyhtf
  • 优化了config.m4,一些配置可以通过pkg-config设置依赖库位置。 @NathanFreeman
  • 优化解析请求头的时候使用动态数组的问题 。 @NathanFreeman

😊 致谢

  • 感谢你们为Swoole v5.1.3做出的贡献,祝愿大家身体健康,万事如意,工作顺利。

v5.1.2

24 Jan 04:09
Compare
Choose a tag to compare
  • Added support for embed sapi @matyhtf
  • Fixed compatibility with PHP 8.3 ZEND_CHECK_STACK_LIMIT @Yurunsoft
  • Fixed no Content-Range response header when the range request returns all the contents of the file @Yurunsoft
  • Optimized HTTP server performance @NathanFreeman
  • Fixed truncated cookie @stnguyen90
  • Fixed native-curl crash on PHP 8.3 @NathanFreeman
  • Added CLOSE_SERVICE_RESTART, CLOSE_TRY_AGAIN_LATER, CLOSE_BAD_GATEWAY as valid close reasons for websocket @cjavad
  • Fixed invalid errno after Server::Manager::wait() @JacobBrownAustin
  • Fixed HTTP2 Typo @leocavalcante

v5.1.1

26 Nov 14:42
b902f1b
Compare
Choose a tag to compare

🐛 Bug Fixed

  • Fixed memory leak issue in HTTP coroutine client @NathanFreeman
  • Fixed the issue of can not hook pdo_odbc @NathanFreeman
  • Fixed the error in executing socket_import_stream() @Yurunsoft
  • Fixed the issue with Context::parse_multipart_data() unable to handle empty request body @NathanFreeman
  • Fixed the issue with PostgreSQL coroutine client where the parameters are not working @Yurunsoft
  • Fixed the bug where curl crashes during destruction @matyhtf
  • Fixed the compatibility issue between Swoole 5.x and the latest version of xdebug @NathanFreeman
  • Fixed the problem of class not found error caused by coroutine switching during the process of class autoloading @Yurunsoft
  • Fixed the issue of not being able to compile Swoole on OpenBSD @ChihHao-Su @twose

🐛 Bug 修复

v5.1.0

29 Sep 06:33
b72d22a
Compare
Choose a tag to compare

✨ New Features

💪 Performance Improvement

🐛 Bug Fixed

  • Fixed the memory leak caused by each request of the WebSocket coroutine client (@matyhtf) (@NathanFreeman)
  • Fixed the issue where graceful shutdown of the HTTP coroutine server was not causing the client to exit (@matyhtf)
  • Fixed the issue where adding the --enable-thread-context option during compilation was causing Process::signal() to not work (@NathanFreeman)
  • Fixed the issue where the connection count was being calculated incorrectly when a process exited abnormally in SWOOLE_BASE mode (@Yunrunsoft)
  • Fixed the incorrect signature of the stream_select() function (@Yunrunsoft) (@NathanFreeman)
  • Fixed the case sensitivity issue with the MIME information in files (@hongweipeng)
  • Fixed the spelling mistake in Http2\Request::$usePipelineRead, which was causing a warning to be thrown in PHP 8.2 environment (@NathanFreeman)
  • Fixed the memory leak issue in SWOOLE_BASE mode (@dongzitai) (@NathanFreeman)
  • Fixed the memory leak issue caused by setting the expiration time of a cookie in Http\Response::cookie() (@NathanFreeman)
  • Fixed the connection leak issue in SWOOLE_BASE mode (@NathanFreeman)

🔑 Kernel

  • Fixed the function signature issue of php_url_encode in Swoole under PHP 8.3 (@YepYuYu)
  • Fixed the issue with unit testing options (@YepYuYu)
  • Optimized and refactored the code (@matyhtf)
  • Fix compatibility with PHP 8.3 (@Yunrunsoft) (@matyhtf)
  • Unsupported compilation on 32-bit operating systems

🌕🥮🥰 Happy Mid-Autumn Festival!

✨ 新特性

💪 性能提高

🐛 Bug 修复

🔑 内核

🌕🥮🥰 祝大家中秋节快乐!

v5.0.3

26 Apr 09:24
Compare
Choose a tag to compare
  • Added --with-nghttp2_dir option, Use the system nghttp2 library
  • Added unit character supports for byte length or size related options
  • Fixed memory leak Server task/pipemessage/finish event callback
  • Added Process\Pool::sendMessage()
  • Added support for max-age to Http\Response:cookie() method
  • No longer thrown error log when http header conflicts
  • No longer thrown error log when the server connection is closed
  • Fixed memory leak caused by Server send_yield

v4.8.13

23 Feb 02:12
48c8a40
Compare
Choose a tag to compare
  • Fixed parameter compatibility of Coroutine::printBackTrace() and debug_print_backtrace()
  • Fixed parsing length is wrong when the websocket server enable http2 and websocket protocols at the same time
  • Refactor curl native to support a curl handle with multiple sockets, such as the curl ftp protocol
  • Support for configuring http2 default settings
  • Improved websocket client, upgrade header contains websocket instead of equal
  • Optimized http client, disable keep-alive when server sends connection close
  • Optimized http client, prohibit adding the Accept-Encoding header without compression library
  • Improved debug info, set password as sensitive parameter under PHP-8.2
  • Fixed memory leak when send_yield occurs in Server::send(), Http\Response::end(), Http\Response::write(), WebSocket/Server::push()
  • Fixed crash when using Table::getMemorySize() before add columns
  • Support HTTP Range Requests

v5.0.2

06 Feb 09:54
6809ae4
Compare
Choose a tag to compare
  • Support for configuring http2 default settings
  • Support xdebug under 8.1 or higher
  • Refactor curl native to support a curl handle with multiple sockets, such as the curl ftp protocol
  • Added $who parameter to Process::setPriority/getPriority
  • Added Coroutine\Socket::getBoundCid()
  • Adjusted the default value of Coroutine\Socket::recvLine/recvWithBuffer $length parameter to 65536
  • Refactor cross-coroutine shutdown feature to make memory release safer and solve the crash problem when a fatal error occurs
  • Added socket property for Coroutine\Client, Coroutine\Http\Client, Coroutine\Http2\Client, allow direct operation of socket resources
  • Support Http\Server to send empty file to http2 client
  • Support graceful restart for Coroutine\Http\Server. When server shuting down, the client connection will no longer be forcibly closed, and only stop listening to new requests
  • Added pcntl_rfork pcntl_sigwaitinfo to list of unsafe function, will be closed when coroutine container starts
  • Refactor Server process manager with base mode, the behavior of shutdown and reload will be consistent with base or process mode

The version-5.0.2 has no backwards incompatible changes

v5.0.1

07 Nov 06:06
71859e7
Compare
Choose a tag to compare
  • Supported PHP-8.2
  • Improved coroutine exception handling, compatible with ext-soap
  • Fixed parameter compatibility of Coroutine::printBackTrace() and debug_print_backtrace()
  • Added pgsql coroutine client LOB supports
  • Fixed Event::add() support for sockets resources
  • Fixed compile error when no zlib
  • Improved websocket client, upgrade header contains websocket instead of equal
  • Optimized http client, disable keep-alive when server sends connection close
  • Optimized http client, prohibit adding the Accept-Encoding header without compression library
  • Improved debug info, set password as sensitive parameter under PHP-8.2
  • Fixed crash when unpack server task parsed to an unexpected string
  • Enhanced Server::taskWaitMulti(), no blocking in coroutine environment
  • Fixed the problem that adding a timer less than 1ms is forced to 0
  • Fixed crash when using table::getMemorySize() before add columns
  • Optimized log function, no longer print screen when writing to the log file fails
  • Modify the expire parameter name of Http\Response::setCookie() to expires, fix #4780