|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jordan Smarty n00b
Joined: 20 May 2003 Posts: 1 Location: Grand Rapids, MI
|
Posted: Tue May 20, 2003 5:50 pm Post subject: Smarty::_read_file() Locking Problem |
|
|
Hello,
I was having problems with Smarty hanging the HTTP server while developing a web site using it. For the longest time, I couldn't find out why it was hanging sometimes and other times not until I looked at the state of the HTTP process. It was listed as 'lockf', meaning that it was locking a file or was waiting for a lock to be released. Come to find out, the editor I am using (joe with emacs bindings) locks the file while editing it. For some reason, Smarty locks the template file while reading from it [in Smarty::_read_File()]. Commenting out the flock() line solves the problem. Is there a reason why the file needs to be locked while being read from, because I thought that usually a file only needs to be locked while modifying it, so that other processes don't read from the file and get outdated information.
Thanks for any information or comments regarding this,
Jordan Nelson
Web Developer
PathWay Internet Services, Inc.
jordan at pathwaynet.com |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue May 20, 2003 6:36 pm Post subject: |
|
|
Good question. I've noticed this problem with various editors myself.
I suspect Smarty is locking to ensure that the file is not touched by another process while it is being read. As you know, any client accessing a page can trigger the recompilation of the template if the sources had changed. This is likely a bad thing if it happens while another client was attempting to read the file.
Perhaps it would be simplest if your editor was configured not to lock the file during edits.
Another approach: use a custom resource to bypass the builtin file handling. Personally, I think that the default "file" resource would be a good thing to abstract into a generic resource. It could also lead to having a "default" resource handler other than "file". I tend to use a db to store my templates, so locking issues are handled with a little-bit more grace.
EDIT: If you think about it, you almost certainly don't need your editor to lock the file while you edit. Perhaps in a multi-user environment, but in that case you are probably using CVS so again, you don't need locks. IMHO, filesystem locking is embarrassingly feeble for synchronization of user data and I'd say only barely passable for momentary filesystem coordination. If you really need single-access data you should consider a proper db. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|