Thread View: pl.comp.lang.perl
2 messages
2 total messages
Started by Andrew Whitehead
Fri, 25 Jul 1997 04:14
problem with simultaneous calls to same script
Author: Andrew Whitehead
Date: Fri, 25 Jul 1997 04:14
Date: Fri, 25 Jul 1997 04:14
37 lines
2722 bytes
2722 bytes
I wondered if anyone could help me out with some advice about a Perl Script I am currently writing.... It is basically a link/banner swap scheme handling set of scripts. The script itself works just fine until I start trying to invoke it through several banners all at once (i.e. placing 8 or so on a page). The setup uses cookies to store code numbers which inform the system which url to link to from the displayed banner. This should not be a problem in itself as each banner on the page has an additional value which tags the name of the cookie which relates to the banner (in other words if there are 8 banners on a page there are 8 associated cookies). Anyway, I am pretty convinced that the problem does not rest here. What I think is causing the problem are multiple accesses to the same files (text files which store details of hits, credits etc. for each simulated 'member' of the scheme. Plus a central 'control' file which totals up numbers of hits, keeps ratios monitored etc. As I mentioned, when I run one banner on its own, there is no problem, when I put several on the page these files start to become corrupted and my guess is that it is because multiple calls to the script are causing read/write operations to get muddled up. Is there anything I can do to ensure that if one instance of the CGI script is running, the other calls to it have to wait until it has finished before they can use it. The strategy I had hoped would work is that I open all the text files needed by the script as soon as it is invoked and keep them open until the very end. I had hoped that whilst a file was open, it could not be accessed by other instances of the script but this appears not to be the case! Anybody got any brainwaves? Help would be greatly appreciated - presumably chat-room type scripts have to deal with this very same problem. Please send any ideas direct to awhitehead@ndirect.co.uk
Re: problem with simultaneous calls to same script
Author: Tom Phoenix
Date: Fri, 25 Jul 1997 13:50
Date: Fri, 25 Jul 1997 13:50
16 lines
1744 bytes
1744 bytes
On 25 Jul 1997, Andrew Whitehead wrote: > Is there anything I can do to ensure that if one instance of the CGI > script is running, the other calls to it have to wait until it has > finished before they can use it. I think you could use the methods in Randal's fourth Web Techniques column, which explains how to use flock() to avoid problems when multiple processes need to modify one file. Hope this helps! http://www.stonehenge.com/merlyn/WebTechniques/ -- Tom Phoenix http://www.teleport.com/~rootbeer/ rootbeer@teleport.com PGP Skribu al mi per Esperanto! Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads