[wp-hackers] Blocking WP_Http_Streams while requesting wp-cron.php

Philip Hetjens philip at hetjens.eu
Thu Feb 19 14:45:24 GMT 2009

Hi everybody,

publishing articles takes round about 100 sec on our Servers. I figured out
why. It seems that the server has problems to open a request to wp-cron.php
after publishing an arcle.

wp tries to open a non-blocking, short-timeouted connection to it self. The
problem is, that the function calls for non-blocking and for timeout are
called after the fopen-command in the class WP_Http_Streams (function
"request"), and so the fopen-command takes a lot of time.

There is a possibility to set the default timeout for fopen. I would suggest
that this is done, look here:

    $old = ini_set('default_socket_timeout', $r['timeout']);
        if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false ===
            $handle = @fopen($url, 'r', false, $context);
            $handle = fopen($url, 'r', false, $context);
    ini_set('default_socket_timeout', $old);

in this solution is the problem that the ini-parameter
default_socket_timeout requires an int, but $r['timeout'] is 0.01. I don't
know, if there are other calls with this short timeout (btw.
socket_set_timeout is also looking for an int parameter).

I have no clue how to proceed. So, it would be nice, if anybody could do the


More information about the wp-hackers mailing list