Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"cache.lock" won't be deleted #48

Closed
ametad opened this issue Aug 26, 2014 · 8 comments
Closed

"cache.lock" won't be deleted #48

ametad opened this issue Aug 26, 2014 · 8 comments

Comments

@ametad
Copy link

ametad commented Aug 26, 2014

Hi everyone,

The cache.lock file is still present after a successful retrieval of the browscap.ini file. Therefore the next time I try to use Browscap->getBrowser() I get an Exception: "temporary file already exists".

The files:

drwxrwxrwt 8 root root 4096 aug 26 17:13 ./
drwxr-xr-x 23 root root 4096 aug 26 16:17 ../
-rw-r--r-- 1 www-data www-data 8180003 aug 26 16:47 browscap.ini
-rw-r--r-- 1 www-data www-data 0 aug 26 16:47 cache.lock

The directory they reside in is, in this case /tmp:

drwxrwxrwt 8 root root 4096 aug 26 17:06 tmp/

Do I overlook something? Or is this a problem, perhaps experienced by others too?

@mimmi20
Copy link
Member

mimmi20 commented Aug 26, 2014

I got this error once today, but after cleaning my cache dir the error did not occur again.

@ametad Could you remove the two @ in the updateCache function and then try again? Could you tell if you got any error or exception in your logs?

This may help us to reproduce the cause of the error.

@ametad
Copy link
Author

ametad commented Aug 27, 2014

Thank you mimmi for your message. Today I am not working, so tomorrow I will have a look at this!

@ametad
Copy link
Author

ametad commented Aug 28, 2014

Steps I took today:

  1. Removed the files in /tmp
  2. Go to website that invoked Browscap->getBrowser();
  3. Looked at logging

The logging do indeed show some insight.

/var/log/apache2/access.log :
192.168.56.101 - - [28/Aug/2014:10:42:07 +0200] "GET /nl/inloggen HTTP/1.1" 500 342 "http://anonymous.local.lan/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"

/var/log/apache2/error.log :
[Thu Aug 28 10:42:29.097017 2014] [:error] [pid 1492] [client 192.168.56.101:2383] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /var/www/anonymous/extensions/yii-browscap/lib/browscap-php/src/phpbrowscap/Browscap.php on line 743, referer: http://anonymous.local.lan/

The rest of the website works and the server is an Ubuntu14.04.
After I try some things to get this working I will get back here with my findings. But please, feel free to give some feedback if you want. I would like to know on how this is intended to work.

@asgrim
Copy link
Member

asgrim commented Aug 28, 2014

Looks like this is duplicate of #20 then

@asgrim asgrim closed this as completed Aug 28, 2014
@ametad
Copy link
Author

ametad commented Aug 28, 2014

Indeed, thanks! I will head over there.

@ametad
Copy link
Author

ametad commented Aug 29, 2014

Hi Asgrim,

I still have a small problem with the cache.lock file. When configured with:
doAutoUpdate = true
localFile = '/path/to/file'
updateMethod = Browscap::UPDATE_LOCAL

... and the path to the local file was incorrect, the cache.lock file still resides and therefore does not allow a next try to update the cache with a corrected path.

A perfectly expected Exception is thrown with the path set wrongly:
file_get_contents(/wrong/path/browscap/full_php_browscap.ini): failed to open stream: No such file or directory
(vendor/browscap/browscap-php/src/phpbrowscap/Browscap.php(1018))

Right after this I set the correct path. But it still gives an error: "temporary file already exists", And when I manually remove cache.lock all works like a charm.

But I think it should work a bit more fault resistance. The problem is that when an Exception is thrown the lock file is not removed anymore. Perhaps it should be better that the fault will be catched first, so the file can be deleted first and then it can be thrown again...?

@mimmi20
Copy link
Member

mimmi20 commented Aug 29, 2014

If you use an local file, please set the autoUpdate to false

@ametad
Copy link
Author

ametad commented Aug 31, 2014

Oke I will do that. It was not clear to me that this is the way it should be done. When using the updateMethod UPDATE_LOCAL, how can you update the cache when you provide a newer version of the ini file locally? That is why I set the autoUpdate to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants