Do not report `AcceptFailed` when timing out in `stream_socket_accept()` for non-blocking listeners
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 領域
- networking
研究方向
Start at the implementation behind stream_socket_accept() and trace how a non-blocking listener with a zero timeout records stream errors. Reproduce the issue with the provided PHP script, then find the relevant stream socket tests and add coverage for the expected no-error result while preserving genuine accept failures.
由索引模型根據 Issue 內容生成。
描述
Description
The following code:
<?php
$server = stream_socket_server(
'tcp://127.0.0.1:0',
context: stream_context_create([
'stream' => [
'error_mode' => StreamErrorMode::Silent,
'error_store' => StreamErrorStore::All,
],
]),
);
stream_set_blocking($server, false);
var_dump(stream_socket_accept($server, 0));
foreach (stream_last_errors() as $error) {
var_dump($error);
}
Resulted in this output:
bool(false)
object(StreamError)#3 (5) {
["code"]=>
enum(StreamErrorCode::AcceptFailed)
["message"]=>
string(35) "Accept failed: Connection timed out"
["wrapperName"]=>
string(6) "stream"
["severity"]=>
int(2)
["terminating"]=>
bool(true)
}
But I expected this output instead:
bool(false)
While it is technically true that accepting a new connection failed, no clients waiting is an expected situation when using a non-blocking listener socket (in particular with a zero-timeout). It is a common pattern to call accept() until no more client connections are returned to quickly drain the listening queue after the polling API marked the listener as readable instead of sending it through the whole polling logic again.
By treating the timeout as a failure with the generic AcceptFailed error code, it becomes impossible to distinguish this situation from genuine failures (such as exhausted file descriptors) without inspecting the message, which is particularly annoying when combined with StreamErrorMode::Exception and greatly diminishes the ergonomics of PHP 8.6’s new polling API and stream error handling logic.
PHP Version
PHP 8.6.0-dev (cli) (built: Sep 24 2026 09:04:46) (NTS)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0-dev, Copyright © Zend by Perforce
with Zend OPcache v8.6.0-dev, Copyright ©, by Zend by Perforce
Operating System
No response
- 主要語言
- C
- 星號
- 40.4k
- 分支
- 8.2k
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 113
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
php/php-src 的其他 Issue
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 76/100
-
Bug Status: Needs Triage
難度 1/5 1 小時以內 新手友好度 90/100
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 78/100
-
Bug Category: Tests Status: Verified
難度 2/5 1-3 小時 新手友好度 68/100
-
Bug SAPI: fpm Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 65/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 1/5 1 小時以內 新手友好度 90/100
-
難度 2/5 1-3 小時 新手友好度 82/100
NVIDIA/k8s-device-plugin#2061 · 1 則留言 ·
-
task
難度 2/5 1-3 小時 新手友好度 70/100
vsanthanam/JBird#429 ·