Moin!
Es wär vielleicht ganz hilfreich, wenn man den Code deiner "Lösung" noch bekommen könnte, und sei es auch "nur" zum Vergleich ...
Ist wahr. So here goes the actually relevant stuff:
$lockfile = "forum_not_in_use.txt";
$lock_timeout = 10; # seconds
GetForumControl()
# Returns 1 if we got the forum under control, 0 if another script instance has still not released control
# after $lock_timeout seconds.
sub GetForumControl() {
my $i;
for ($i=$lock_timeout; $i>=0; $i--) {
unlink("$baseurldir/$mesgdir/$lockfile") && return 1;
sleep(1);
}
return 0;
}
ReleaseForumControl()
# Anything to say about this one?
sub ReleaseForumControl() {
local *LFH;
open(LFH, ">$baseurldir/$mesgdir/$lockfile") return; # an error at this point is a bad omen
print LFH "There's currently no posting being processed, so feel free.\n";
close(LFH);
}
main()
# This is main, the alpha and omega.
sub main() {
# First slurp in the data submitted by the form, then evaluate and put
# it into a few variables
parse_form();
get_variables();
# Get the forum under control
unless (GetForumControl()) { # After $lock_timeout seconds still not unlocked?
# Violently unlock, but do not write the posting; instead, raise a timeout error
# If we would write the posting now, a third instance could perform a violent unlock
# while we do our stuff.
ReleaseForumControl();
error('forum_locked');
exit;
}
&get_number; # Get the Data Number
&new_file; # Open the new file and write information to it.
&main_page; # Open the Main WWWBoard File to add link
# Now Add Thread to Individual Pages
if ($num_followups >= 1) {
&thread_pages;
}
&return_html; # Return the user HTML
&increment_num; # Increment Number
ReleaseForumControl(); # Done.
}
main();
Der Code geht ueberigens auf eine Idee von Jörk Behrends zurueck, der in
<../../sfarchiv/1999_1/t01858.htm#a8468> anmerkte, dass sich eine Datei nur einmal korrekt
loeschen laesst und dieser Vorgang betriebssystemintern ordentlich synchronisiert sein sollte.
So long