Changeset 118627 in spip-zone
- Timestamp:
- Nov 14, 2019, 1:58:53 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/cache_cool/trunk/cache_cool_options.php
r118625 r118627 314 314 } 315 315 316 317 /** 318 * Un curl async 319 * @param string $url 320 * @return bool 321 */ 316 322 function cache_cool_async_curl($url){ 317 323 // Si fsockopen est possible, on lance l'url via un socket … … 321 327 $fp = @fsockopen($parts['host'],isset($parts['port'])?$parts['port']:80,$errno, $errstr, 30); 322 328 if ($fp) { 329 $timeout = 200; // ms 330 stream_set_timeout($fp, 0, $timeout * 1000); 323 331 $query = $parts['path'].($parts['query']?"?".$parts['query']:""); 324 332 $out = "GET ".$query." HTTP/1.1\r\n"; … … 326 334 $out.= "Connection: Close\r\n\r\n"; 327 335 fwrite($fp, $out); 336 spip_timer('cache_cool_async_curl'); 337 $t = 0; 338 // on lit la reponse si possible pour fermer proprement la connexion 339 // avec un timeout total de 200ms pour ne pas se bloquer 340 while (!feof($fp) and $t < $timeout) { 341 @fgets($fp, 1024); 342 $t += spip_timer('cache_cool_async_curl', true); 343 spip_timer('cache_cool_async_curl'); 344 } 328 345 fclose($fp); 329 346 return true; … … 346 363 return false; 347 364 } 348 ?>
Note: See TracChangeset
for help on using the changeset viewer.