why does this simple counter fail?

Frédéric Perrin fred at resel.fr
Wed Mar 23 18:35:09 UTC 2011

Gary Kline <kline at thought.org> writes:
> 	Can any of you php hackers tell me why this simple self-hacked
> 	counter bomb?

As others said, what does 'this simple counter bomb' means?

        > $fp = fopen($directory.$file, "r+");
        > flock($fp, 1);

You want an exclusive lock (LOCK_EX, which is 2 is you use some ancient
PHP), not a shared lock.

When updating the file:
	> fputs($fp, $count);
	> fputs($fp, "\n");
        > fputs($fp, $file);

Why do you feel the need to store the filename inside the file itself?
You don't seem to need it after.

Frédéric Perrin -- http://tar-jx.bz

More information about the freebsd-questions mailing list