On Thu, Mar 16, 2006 at 01:29:57AM -0700, Bob Proulx wrote:
Let me suggest the following instead:
unlink($conf::build_dir/current-$main::distribution);
symlink($main::pkg_logfile,$conf::build_dir/current-$main::distribution.$$) or
die;
rename($conf::build_dir/current-$main::distribution.$$,$conf::build_dir/current-$main::distribution)
or die;
I considered something like that...
I'm not sure what you expect the end result to be if two processes try
and operate at the same time. It may be that you need a locking
mechanism for this to make sense.
Agreed. But avoiding needing locking when possible is better.
...but without knowing what the end result is, I didn't see it as an
improvement. That is, if two processes are writing at the same time,
one's output is going to get clobbered--if one gets clobbered atomically
I don't see an obvious advantage. If you have an actual locking scheme
you can determine the order of what happens; otherwise you're just
guessing, especially since it looks like there are *two* files involved
(the rename scheme can't atomically handle both of them). If you are
going to do the symlink/rename scheme I'd also use a better random
filename than $$. It's also not necessary to do the unlink in that
case--actually it's better not to, since the rename will clobber the
destination anyway.
Mike Stone
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]