Embed
Embed copied to clipboard
Awesome library, but it keeps files open
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).
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.
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.
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).
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.
FWIW, setting these options to true in the CurlDispatcher config seems to solve the problem...
CURLOPT_FORBID_REUSE
CURLOPT_FRESH_CONNECT