in reply to Re: CGI counter resets for no obvious reason
in thread CGI counter resets for no obvious reason

I never lock counter files and it always works fine, so I don't thinks it's neccessary.. *boggle*

Personally, I never lock my house door and my stuff is always there when I get back so I don't think doors are necessary.

Updated I didn't intend this to be mean but seriously, people haven't invented multiple ways to file lock just out of sheer boredom or for the excitement of it.

--
$you = new YOU;
honk() if $you->love(perl)

  • Comment on Re: Re: CGI counter resets for no obvious reason

Replies are listed 'Best First'.
Re: Re: Re: CGI counter resets for no obvious reason
by damian1301 (Curate) on Jan 30, 2001 at 21:25 UTC
    Yea, file locking is very important nomatter how unimportant you think it is. I made a really simple counter a couple weeks ago and my friend and I tested it. As soon as we both accessed the counter at the same time the '1' went to a '2.46578837244004' or something like that. I think the counter was along the lines of:
    $cfile="counter.txt"; open(COUNT,$cfile); $count=<COUNT>; $count++; close(COUNT); open(COUNT,">$cfile"); print COUNT $count; close(COUNT); print "content-type: text/html\n\n"; print $count;
    (pretty confusing at first glance, eh?) Notice that there is no flock in there or any type of locking. Here are some links you should check out.
    Simple locking
    File locking
    flock
    Fcntl

    Wanna be perl hacker.
    Dave AKA damian

    I encourage you to email me
Re: Re: Re: CGI counter resets for no obvious reason
by flocto (Pilgrim) on Jan 31, 2001 at 03:56 UTC
    okok, I correct myself: For my special purpose(s) filelocking wasn't necessary. Everybody who wants to write serious counter-applications (not just for fun) should lock his/her files and make backups every now and then..

    octopus
    --
    GED/CC d-- s:- a--- C++(+++) UL+++ P++++$ L++>++++ E--- W+++@ N o? K? w-- O- M-(+) V? !PS !PE !Y PGP+(++) t-- 5 X+ R+(+++) tv+(++) b++@ DI+() D+ G++ e->+++ h!++ r+(++) y+