Bug #50312 [Asn->Csd]: Opening an https using fopen consumes all cpu time

From: Date: Sun, 01 Feb 2015 04:42:17 +0000
Subject: Bug #50312 [Asn->Csd]: Opening an https using fopen consumes all cpu time
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190378@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50312&edit=1

 ID:                 50312
 Updated by:         rasmus@php.net
 Reported by:        kvr at centrum dot cz
 Summary:            Opening an https using fopen consumes all cpu time
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            OpenSSL related
 Operating System:   *
 PHP Version:        5.*, 6
 Assigned To:        rasmus
 Block user comment: N
 Private report:     N

 New Comment:

This doesn't happen anymore. As we can see from the strace, we now sit in poll() until the
timeout at 60s:

29667 1422765514.330841 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 <0.000027> 
29667 1422765514.330914 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) <0.000014>
29667 1422765514.330967 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 <0.000015>
29667 1422765514.331025 connect(3, {sa_family=AF_INET, sin_port=htons(443),
sin_addr=inet_addr("123.125.114.144")}, 16) = -1 EINPROGRESS (Operation now in progress)
<0.000050>
29667 1422765514.331138 poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 60000) = 0
(Timeout) <60.060063>
29667 1422765574.391342 fcntl(3, F_SETFL, O_RDWR) = 0 <0.000049>
29667 1422765574.391565 close(3)        = 0 <0.000076>


Previous Comments:
------------------------------------------------------------------------
[2009-11-27 20:12:07] kvr at centrum dot cz

Not personally as it's not my case :) But yes, I mean to take care
when stream_select is called, not to perform system select/poll on
one ssl socket.

------------------------------------------------------------------------
[2009-11-27 19:13:28] rasmus@php.net

kvr, you mean you are worried about nested selects if you are doing a 
stream_select() in userspace and internally the SSL reading is 
selecting as well?

------------------------------------------------------------------------
[2009-11-27 18:56:49] pajoye@php.net

btw, if it happens to be the same issue, can you bogus (duplicate) this one pls?

------------------------------------------------------------------------
[2009-11-27 18:54:58] rasmus@php.net

It's not so much a matter of reproducing it as it is reading the 
openssl docs and looking at our code.  If you read about SSL_read and 
SSL_get_error it seems pretty clear that we are not handling errors 
efficiently here.  We are simply busy-looping on an SSL_ERROR_WANT_READ 
which is something you are going to have a hard time reproducing 
consistently, but when it happens it sucks.

------------------------------------------------------------------------
[2009-11-27 18:42:36] pajoye@php.net

IIRC I did not blew it, I was simply not able to reproduce this problem, same as here.  I did not
blindly apply the patch as every attempt to fix smtg that was not reproducable always had bad side
effect.

I'm still not able to reproduce, Rasmus, feel free to take the hand on both bugs if you can
reproduce these problems and can fix them.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=50312


--
Edit this bug report at https://bugs.php.net/bug.php?id=50312&edit=1


Thread (18 messages)

« previous php.bugs (#190378) next »