Do not report `AcceptFailed` when timing out in `stream_socket_accept()` for non-blocking listeners
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 55/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Domaine
- networking
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- C
- Étoiles
- 40.4k
- Forks
- 8.2k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 113
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de php/php-src
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
Bug Status: Needs Triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Flaky hrtime.phpt test OuverteBug Category: Tests Status: Verified
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Bug SAPI: fpm Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Toutes les issues de php/php-src
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
NVIDIA/k8s-device-plugin#2061 · 1 commentaire ·
-
task
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
vsanthanam/JBird#429 ·