Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Curl POST Problem Causing PHP to use 100% CPU

Tags:

php

curl

libcurl

I'm trying to upload data with POST to my webserver but sometimes cURL just stalls and causes PHP to use 100% CPU indefinitely.

I'm using the code below.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
curl_setopt($curl, CURLOPT_HEADER, true);
$page = curl_exec($curl);
curl_close($curl);

Any insight to what is causing or how to track this issue would be great.

like image 558
DramaGirl Avatar asked Nov 26 '22 17:11

DramaGirl


1 Answers

If it really is the actual curl "call" that hangs and performs 100% CPU, then that is a curl bug and you should probably consider upgrading your libcurl.

like image 190
Daniel Stenberg Avatar answered Dec 18 '22 09:12

Daniel Stenberg