Hi,
 
In the accounting process, i notice that one user quota being assigned to another user.  i am using the accounting.pl that comes with LPRng with some change.
 
as acct shows, there are two jobs logs and they are mixed up together.
i.e the job from alexeev shows up before user 'smiles' finish his job. later  user 'smiles' finish his job first.  
i think that causes my problem. because in the accounting.pl, i assume i am dealing with one user at a time and get their quota, printed pages then update the quota database. now when two jobs mixed up, i may end up updating one user quota for another ..
 
following is the acct log and the part i do accounting in the accounting.pl.
can you give me some suggestion as i am not sure how do i deal with this case..
 
START '[EMAIL PROTECTED]' 'P=printer4' 'n=smiles' 'H=130.63.230.132' 'D=1071447451'
filestart '-q20472' '-p356696' '-t2003-12-14-19:17:32.373' '[EMAIL PROTECTED]' '-nsmiles' '-Pprinter4'
START '[EMAIL PROTECTED]' 'P=printer4' 'n=alexeev' 'H=130.63.230.132' 'D=1071468880'
filestart '-q21170' '-p356749' '-t2003-12-15-01:14:41.893' '[EMAIL PROTECTED]' '-nalexeev' '-Pprinter4'
fileend '-b4' '-T54' '-q21170' '-p356753' '-t2003-12-15-01:15:34.576' '[EMAIL PROTECTED]' '-nalexeev' '-Pprinter4'
END 't=21429' 'p=53' 's=356696' 'q=356749' 'D=1071468880' '[EMAIL PROTECTED]' 'P=printer4' 'n=smiles' 'H=130.63.230.132' 'S=1071447451'
END 't=55' 'p=4' 's=356749' 'q=356753' 'D=1071468935' '[EMAIL PROTECTED]' 'P=printer4' 'n=alexeev' 'H=130.63.230.132' 'S=1071468880'

 
here is what i have in the accounting.pl .
the part after ## update db ## is my change.
 
for( my $i = @stack -1; $i >= 0 ; --$i ){
    $_ = $stack[$i];
    print STDERR "stack [$i] '$_'\n" if $debug;
    if( /^[a-z]*end .*-p(\d+)/ ){
        $end_counter = $1;
    } elsif( /^[a-z]*start .*-p(\d+)/ ){
        $start_counter = $1;
    } elsif( /^START/ ){
        # we now update the accounting information
        ($start_time) = /D=(\d+)/;
        s/D=(\d+)/S=$1/;
        $count = $end_counter - $start_counter;
        $elapsed = $time - $start_time;
        # you should put your make update record stuff here
        s/^START/END 't=$elapsed' 'p=$count' 's=$start_counter' 'q=$end_counter' 'D=$time'/;
        $out = $_ . "\n" . $out;
        $end_counter = $start_counter;
        $time = $start_time;

        handle_error("Printing Halted.")
                if ($count=~/-/);
                #######################@@
                ## update db
                #######################@@
                connect_db();
                $pages = check_page_count();
                $remain = $pages-$count;
                ## inform user s/he has no print quota left.
                unless ($remain) {
                    my $msg = "Your Print Quota is 0 now";
                    `$rmssh $uname $msg`;
                }
                update_db($remain);
                ## @@ write job.history
                write_history('');
                $dbh->disconnect() if $dbh;
    }
}
 
 



Post your free ad now! Yahoo! Canada Personals

Reply via email to