[Home]POPFile/TestCodeForForkingProblem

Amatubu_Wiki | POPFile | RecentChanges | Preferences

Test code for check the Forking Problem with Kakasi

What is the test code?

How to use the test code?

The test code

#!/usr/bin/perl

use strict;
use POPFile::Mutex;

my $kakasi_mutex = new POPFile::Mutex( 'mailparse_kakasi' );

for (1..3) {
    my $pid = fork();
    
    if ($pid != 0) {
        next;
    } else {
        for (1..1000) {
            kakasi_test();
        }
        last;
    }
}

sub kakasi_test {
    my $line = "POPFile はベイズ推定を利用して電子メールを自動的に分類する " .
        "POP3 プロキシー、および Web インターフェースで、強力なスパムフィルター" .
        "としても威力を発揮します。ほとんどどのプラットフォームでも、どのメール" .
        "クライアントとも動作します。 ";
    
    use Text::Kakasi;
    
    $kakasi_mutex->acquire();
    
    log_("Text::Kakasi start.");
    
    Text::Kakasi::getopt_argv("kakasi", "-w -ieuc -oeuc");
    $line = Text::Kakasi::do_kakasi($line);
    Text::Kakasi::close_kanwadict();
    
    $kakasi_mutex->release();
    
    log_("Text::Kakasi done.");
}

sub log_ {
    my ($msg) = $_;
    
    print STDERR "$$: $msg\n";
}

The log

The code will output a log. Here is a example:

 -1252:Text::Kakasi start.
 -1252:Text::Kakasi done.
 -1252:Text::Kakasi start.
 -1252:Text::Kakasi done.
 -1252:Text::Kakasi start.
 -748:Text::Kakasi start.
 -748:Text::Kakasi done.

The log shows that Text::Kakasi of the process -748 started before the process -1252 had done. Then, perl.exe crashed.


Amatubu_Wiki | POPFile | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited January 8, 2005 14:11 by Amatubu (diff)
Search:

Copyright (c) 1996-2006 naoki iimura e-mail