# Maia Mailguard can't find Fork or threads



## BobWalter (Apr 25, 2012)

I installed postfix/dovecot/maia on FreeBSD 8.2 amd64. All works correctly except the Maia cron job that wants fork or threads. I verified that perl forks is available (installed from ports collection), however the maia configtest as well as the cron job that wants forks/threads can not find it. Since there are many *F*reeBSD maia installs, I am wondering if there is an issue with the amd64 version.

I contacted the maia port manager but he failed to answer. Can anyone help me untangle this?

Thanks,
Bob


----------



## SirDice (Apr 26, 2012)

What is the exact error message?


----------



## BobWalter (Apr 27, 2012)

Actually, there aren't error messages per se. If I run configtest.pl, it just hangs. By process of elimination (commenting out tests one at a time), I discovered the test for forks is where it hangs.

When I run `# /var/maiad/maia/scripts/process-quarntine.pl --learn --report`
I get

```
"Perl module 'forks' not installed, and 'threads' support not available"
```

The code generating this message is:

```
# Try to use the forks module first
eval {
   require forks;
   forks->import();
};
if ($@) { # fall back to using threads if available 
	eval {
	   require threads;
	   threads->import();
	   $use_threads = 1;
	};
	if ($@) {
		die ("Perl module 'forks' not installed, and 'threads' support not available.");
    }	
}
```

I verified that the ports collection has forks installed. 

I commented out the last "if" clause so the script would run even without detecting forks or thread support. 
When run from the cron tab, the process never closes. I killed the running process and then ran the script from the command prompt.

I changed the maia log level to 'debug' to see what the output would be.  As you can see, the script appears to be processing mail in some respect. 


```
$ /var/maiad/maia/scripts/process-quarantine.pl --learn --report
 (16362): Error 57 when sending message to server: Socket is not connected at
 /usr/local/lib/perl5/site_perl/5.10.1/mach/forks.pm line 3633
        threads::_croak('Error 57 when sending message to server: Socket is not connected') called at
 /usr/local/lib/perl5/site_perl/5.10.1/mach/forks.pm line 2406
        threads::_send(undef, '_waitppid2ctid', 16362) called at /usr/local/lib/perl5/site_perl/5.10.1/mach/forks.pm line 2504
        threads::_command('_waitppid2ctid', 16362) called at /usr/local/lib/perl5/site_perl/5.10.1/mach/forks.pm line 820
        threads::new('threads', 'HASH(0x804340588)', 'CODE(0x803b22508)', 'ARRAY(0x8043403a8)') called at
 /var/maiad/maia/scripts/process-quarantine.pl line 254
$ splice() offset past end of array at /usr/local/lib/perl5/5.10.1/mach/DB_File.pm line 173.
Use of uninitialized value $DB_File::splice_end_array in pattern match (m//) at
 /usr/local/lib/perl5/5.10.1/mach/DB_File.pm line 174.
netset: cannot include 127.0.0.1/32 as it has already been included
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
Parsing of undecoded UTF-8 will give garbage when decoding entities at /usr/local/lib/perl5/site_perl/5.10.1/Mail/SpamAssassin/HTML.pm line 248.
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting
reporter: SpamCop message older than 2 days, not reporting

$
```

Looking at the log (debug level):

```
2012-04-27 10:05:33 [16362] Removing stale lock file [56264]
2012-04-27 10:05:33 [16362] Writing lock file [16362]
2012-04-27 10:05:33 [16362] Starting
2012-04-27 10:05:33 [16362] Running as user = vscan
2012-04-27 10:05:33 [16362] Parallel processing model = forks
2012-04-27 10:05:33 [16362] workers = 10
2012-04-27 10:05:33 [16362] max-size = 262144 bytes
2012-04-27 10:05:33 [16362] learn = Yes
2012-04-27 10:05:33 [16362] autolearn ham <= -5
2012-04-27 10:05:33 [16362] autolearn spam >= 6
2012-04-27 10:05:33 [16362] autoreport spam >= 15
2012-04-27 10:05:33 [16362] report = Yes
2012-04-27 10:05:33 [16362] report to Razor = Yes
2012-04-27 10:05:33 [16362] report to Pyzor = Yes
2012-04-27 10:05:33 [16362] report to DCC = Yes
2012-04-27 10:05:33 [16362] report to SpamCop = Yes
2012-04-27 10:05:33 [16362] spam-only = No
2012-04-27 10:05:33 [16362] ham-only = No
2012-04-27 10:05:33 [16362] dry-run = No
2012-04-27 10:05:33 [16362] log-level = 4 (DEBUG)
2012-04-27 10:05:33 [16362] 1363 emails ready for processing, 10 workers available
2012-04-27 10:05:52 [16370] Processing email 2164, type SPAM, score  7.321, autolearn = 'no'
2012-04-27 10:05:57 [16370] Learned mail item 2164 as spam and reported it
2012-04-27 10:05:57 [16370] Processing email 2448, type SPAM, score  5.563, autolearn = 'no'
2012-04-27 10:06:02 [16370] Learned mail item 2448 as spam and reported it
2012-04-27 10:06:02 [16370] Processing email 2545, type SPAM, score 14.889, autolearn = 'spam'
2012-04-27 10:06:03 [16370] Learned mail item 2545 as spam and reported it
```

I eliminated a lot of duplicated lines.

Apparently some work is being done. I have not received any confirmation emails from SpamCop yet. If the script is, in fact working, I am still unable to run it under cron since the job never terminates. 

It would be my hope to figure out how to get this script to see forks, failing that, getting the job to complete under cron would be a big help.

Thanks,
Bob


----------



## scott4long (Nov 14, 2013)

Hi Bob, did you ever find a resolution for this?  I'm having the exact same problem.


----------

