Embed icon indicating copy to clipboard operation
Embed copied to clipboard

Awesome library, but it keeps files open

Open dionmes opened this issue 7 years ago • 5 comments
trafficstars

Hi,

I love this library. However it seems to keep files open after a curl request. I cannot seem to find where exactly but it varies between 2-6 files after a request.

(It looks like it is something in the CURL call).

dionmes avatar Jul 17 '18 08:07 dionmes

I cannot detect this. All curl request should be closed, as you can see here: https://github.com/oscarotero/Embed/blob/master/src/Http/CurlDispatcher.php#L157 and here: https://github.com/oscarotero/Embed/blob/master/src/Http/CurlDispatcher.php#L253

Can you provide more information? Thanks.

oscarotero avatar Jul 17 '18 08:07 oscarotero

I call the embed object from a self written Laravel console command, for a couple of hundred urls to populate a db. This didn’t go well, when I checked the open files, they increase after each call to the object.

dionmes avatar Jul 17 '18 08:07 dionmes

Ok, I have narrowed it down to the curl_exec function in CurlDispatcher\exec . It might be a curl specific thing (I don't know the curl object), will look into that. (curl_close does not seem to free the file handlers).

dionmes avatar Jul 17 '18 11:07 dionmes

Can not seem to find what curl is doing to keep the file open, given up. As far as I see now it only causes problems in a script which runs the object a lot of times. I expect a web call to close it after every request but I haven't checked.

dionmes avatar Jul 18 '18 08:07 dionmes

FWIW, setting these options to true in the CurlDispatcher config seems to solve the problem...

CURLOPT_FORBID_REUSE CURLOPT_FRESH_CONNECT

geoffoliver avatar Jan 01 '20 23:01 geoffoliver