php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79497 stream_socket_client() throws an unknown error sometimes with <1s timeout
Submitted: 2020-04-20 01:53 UTC Modified: -
From: joey dot cai at gmail dot com Assigned:
Status: Closed Package: OpenSSL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joey dot cai at gmail dot com
New email:
PHP Version: OS:

 

 [2020-04-20 01:53 UTC] joey dot cai at gmail dot com
Description:
------------
stream_socket_client() can throw an unknown error when connection timeout is set to less than 1s due to a bug in php_openssl_subtract_timeval()

A PR has been raised https://github.com/php/php-src/pull/5422 

Test script:
---------------
https://gist.github.com/joec4i/ef1b1156ed79e23487400c68a5f693cb

// To test, run `php socket_test.php 10000 0.9 | grep error`

Expected result:
----------------
No connection errors

Tested X connections(timeout=0.1) with in xs with 0 errors

Actual result:
--------------
failed in 0.0037751197814941s, error.no=0, errstr=
failed in 0.0031719207763672s, error.no=0, errstr=
failed in 0.0026381015777588s, error.no=0, errstr=
failed in 0.0029230117797852s, error.no=0, errstr=
failed in 0.0027728080749512s, error.no=0, errstr=
Tested 2000 connections(timeout=0.9) with in 6.1318738460541s with 5 errors

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-20 08:27 UTC] nikic@php.net
Automatic comment on behalf of joe.cai@bigcommerce.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=94e09bfe558656d3f1470dc960b900a951b0dffc
Log: Fix #79497: Fix php_openssl_subtract_timeval()
 [2020-04-20 08:27 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC