|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36479 fread using 99% CPU in Windows with SSL Connection
Submitted: 2006-02-21 18:03 UTC Modified: 2007-07-25 01:00 UTC
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: joel dot washburn at gmail dot com Assigned: pollita (profile)
Status: No Feedback Package: Streams related
PHP Version: 5.1.3-dev OS: Windows (Any)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: joel dot washburn at gmail dot com
New email:
PHP Version: OS:


 [2006-02-21 18:03 UTC] joel dot washburn at gmail dot com
php.exe uses 99% CPU while polling SSL sockets for data.  I can reproduce this issue in IIS and Apache using php5isapi.dll and php5apache2.dll.

This is a nightmare for php scripts using third party API calls via SSL sockets.  If the API call takes a few seconds to run, the CPU is maxed out waiting on a response.

This is not an issue on linux systems.

This is not an issue on Windows using clean sockets (only SSL).

Reproduce code:
Below is a simple way to reproduce the problem with fgets():

Create two files, one (timer.php) has to be accessable from the web
(HTTP and HTTPS) and the other can be ran from the command prompt
(pingtimer.php).  When you run pingtimer.php using SSL, php.exe will
stick at 99% CPU in Task Manager.  When you run it using clean sockets,
its idle while waiting for a response.

timer.php :
        print "<html><body>10 sec. are up!</body></html>";

        //$sock = fsockopen("localhost", 80);
        $sock = fsockopen("ssl://localhost", 443);

        $query = "GET /timer.php HTTP/1.1\r\n";
        $query .= "Host: localhost\r\n";
        $query .= "Connection: Close\r\n\r\n";

        fwrite($sock, $query);
        while (!feof($sock)) {
                echo fgets($sock, 128);

Expected result:
CPU usage should be very little or zero while waiting for a response.

Actual result:
99% CPU usage in Windows Task Manager from php.exe while waiting on a response.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-22 08:31 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-02-23 20:51 UTC] joel dot washburn at gmail dot com
The issue was not resolved with 5.1.3-dev.
 [2006-02-23 20:59 UTC]
Sara, could you take a look at it?
 [2006-03-24 00:40 UTC] joel dot washburn at gmail dot com
Any progress on this issue?
 [2007-07-17 21:11 UTC]
Please try using this CVS snapshot:
For Windows (zip):

For Windows (installer):

There were some fixes in the related files, please try it out.
 [2007-07-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 12:01:32 2024 UTC