Article View: pl.comp.lang.perl
Article #447problem with simultaneous calls to same script
From: 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
Technical Details
Message-ID:
<01bc98b0$dc2af4c0$70fe4ac2@awhitehead>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!uw.edu.pl!news.icm.edu.pl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!baron.netcom.net.uk!netcom.net.uk!news-peer!btnet-feed2!hades.ndirect.co.uk!194.74.254.112Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!uw.edu.pl!news.icm.edu.pl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!baron.netcom.net.uk!netcom.net.uk!news-peer!btnet-feed2!hades.ndirect.co.uk!194.74.254.112 From: "Andrew Whitehead" <awhitehead@netmart.co.uk> Newsgroups: comp.lang.perl.misc,de.comp.lang.perl,pl.comp.lang.perl Subject: problem with simultaneous calls to same script Date: 25 Jul 97 04:14:33 GMT Organization: NET-Mart Central UK Limited Lines: 38 Message-ID: <01bc98b0$dc2af4c0$70fe4ac2@awhitehead> NNTP-Posting-Host: hades.ndirect.co.uk X-Newsreader: Microsoft Internet News 4.70.1161 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit