Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Do not report `AcceptFailed` when timing out in `stream_socket_accept()` for non-blocking listeners

オープン
#23,879 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, php
領域
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 の本文から書いたものです。

説明

Bug Category: Streams Status: Needs Triage
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時間
マージ済み PR(30日)
113

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

php/php-src のほかの issue

php/php-src の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。