Ticket #18738: 18738-curl_multi.patch
File 18738-curl_multi.patch, 1.8 KB (added by , 12 years ago) |
---|
-
wp-includes/class-http.php
1022 1022 private $headers = ''; 1023 1023 1024 1024 /** 1025 * Curl multi resource handle 1026 * @var mixed 1027 */ 1028 public $curl_multi = null; 1029 1030 /** 1031 * List of curl handles 1032 * @var array 1033 */ 1034 private $curl_handles = array(); 1035 1036 /** 1025 1037 * Send a HTTP request to a URI using cURL extension. 1026 1038 * 1027 1039 * @access public … … 1146 1158 1147 1159 // We don't need to return the body, so don't. Just execute request and return. 1148 1160 if ( ! $r['blocking'] ) { 1149 curl_exec( $handle ); 1150 curl_close( $handle ); 1161 $this->curl_handles[] = $handle; 1162 $this->curl_multi = curl_multi_init(); 1163 curl_multi_add_handle( $this->curl_multi, $handle ); 1164 curl_multi_exec( $this->curl_multi, $active ); 1165 add_action( 'shutdown', array( $this, 'close_connections' ) ); 1151 1166 return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); 1152 1167 } 1153 1168 … … 1228 1243 1229 1244 return apply_filters( 'use_curl_transport', true, $args ); 1230 1245 } 1246 1247 /** 1248 * Wait for any multi-requests to finish or time out and close the connection 1249 */ 1250 public function close_connections() { 1251 $mrc = $active = null; 1252 1253 // Make sure all of the requests have finished 1254 // but don't listen for a response 1255 do { 1256 $mrc = curl_multi_exec( $this->curl_multi, $active ); 1257 } while ( $active && $mrc == CURLM_CALL_MULTI_PERFORM ); 1258 1259 // Close all handles, and the multi handle 1260 foreach ( $this->curl_handles as $handle ) 1261 curl_multi_remove_handle( $this->curl_multi, $handle ); 1262 curl_multi_close( $this->curl_multi ); 1263 } 1231 1264 } 1232 1265 1233 1266 /**