> Kan du poste den del af koden, hvor du bruger flock. Du bruger muligvis
> flock forkert ?
open(COUNTS,"<$root/count.txt") || error("Can't open the
file($root/count\.txt) $0: $!");
$counts = <COUNTS>;
close(COUNTS);
$loops = 3;
if ($loops <= $counts){
# check log times, remove expired
open(CCOO,">$root/count\.txt") || error("Can't open the
file($root/count\.txt) $0: $!");
require "$cgi_root/lock_stuff.cgi";
&lock("CCOO");
print CCOO "0";
&unlock("CCOO");
close(CCOO);
opendir(STAT,"$root/log/users") || print "DIRECTORY READING ERROR
(log/users)<BR>\n";
@dir = readdir(STAT);
closedir(STAT);
foreach $line (sort @dir){
if ($line ne '.' && $line ne '..'){
$kick_idle_user = $line;
$kick_idle_user =~ s/\.cgi//gi;
open(USER,"<$root/log/users/$line") || die "open $root/log/users/$line: $!";
$user_read = <USER>;
close(USER);
$check = time() - $user_read; #count seconds
#hvis brugeren er idle:
if ($check >= $idle){
require "$cgi_root/get_user_info.cgi";
@count_user_data = &get_user_info($kick_idle_user);
if($count_user_data[0] == 1){
$count_rooms = $count_user_data[5];
}elsif($count_user_data[0] == 0){
$count_rooms = $count_user_data[2];
}
open(KICK_IDDLE,">>$root/rooms/$count_rooms\.cgi") || &error("Can't open the
file($root/rooms/$count_rooms\.cgi) $0: $!");
require "$cgi_root/lock_stuff.cgi";
&lock("KICK_IDDLE");
print KICK_IDDLE "*** <FONT COLOR=\"$amc\"
SIZE=\"$amc_size\"><B>$count_user_data[1]</b> has been kicked for idle time
<font color=\"ff0000\"><b>($check
seconds)</b></font>.<blink>Bye!</blink></FONT>\n";
&unlock("KICK_IDDLE");
close(KICK_IDDLE);
require "$cgi_root/kick_stuff.cgi";
&kick($kick_idle_user, "idle");
}
}
}
}
}
sub lock {
if($^O !~ /win/i){
flock($_[0],LOCK_EX);
}else{
binmode($_[0]);
}
#seek($_[0], 0, 2);
}
sub unlock {
if($^O !~ /win/i){
flock($_[0],LOCK_UN);
}
}
Well, såda ser det circa ud.
Problemet opstår i $check = time() -
$user_read; #count seconds .. nogle gange bliver $user_read lige med NULL,
og dette forstår jeg ikke..