php / php/php-src

Socket maximum timeout of 2147 seconds?

Đang mở
#17,717 2 bình luận 1 reaction 1 người được giao Xem trên GitHub

@cmb69 đang làm issue này rồi.

Từ ngày 6/2/2025.

  • #17720 của @cmb69 — đang mở
Bug Extension: standard OS: Windows Status: Verified
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

Description

The following code:

<?php
$url = 'https://example.com/';
$context = stream_context_create([
  'http' => [
    'timeout' => 60 * 60,
  ],
]);
file_get_contents($url, false, $context);

Resulted in this output:

file_get_contents(https://example.com/): Failed to open stream: timeout must be lower than 2147

But I expected this output instead:

No warning/error

Relavant code for the max value from the output ( floor((2^31 -1) / 1000000 ) = 2147 ):
https://github.com/php/php-src/blob/cdaa69e1224bac08be5cdca58191e096613c5766/ext/standard/http_fopen_wrapper.c#L245-L251
Dividing by 100000.0 doesn't seem right.

The timeout struct accepts two long integers, one for seconds and one for micro seconds so the maximum value should be 2147483647.999999 seconds.

https://github.com/php/php-src/blob/cdaa69e1224bac08be5cdca58191e096613c5766/ext/standard/http_fopen_wrapper.c#L259-L265

My php binary is from https://windows.php.net/downloads/releases/php-8.4.3-Win32-vs17-x64.zip

PHP Version

PHP 8.4.3 x64

Operating System

Windows 10

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.