Can bogofilter run by multiprocess at the same time

Matthias Andree matthias.andree at gmx.de
Tue Oct 19 21:30:49 CEST 2004


.™.æ.».Â’. <john.chen at net263.com> writes:

> the bogofiler version is 0.15.7. Following is the backtrace when
> bogofilter hangs:
> #0  0xff218d4c in _read () from /usr/lib/libc.so.1
> #1  0xff209a10 in _filbuf () from /usr/lib/libc.so.1
> #2  0x0001c5a0 in xfgetsl (
>     buf=0x67b342
> "SFQ6IGdyYXkgM3B0IGRvdWJsZTs></o:p></SPAN></SPAN></P></TD> \n   <TD 
> \n    style=\"BORDER-RIG", max_size=6804290, in=0x155e68,
>     no_nul_terminate=1) at fgetsl.c:39
> #3  0x0001a560 in buff_fgetsl (self=0x67d342, in=0x67d342) at
> buff.c:63

I am tempted to believe the problem is in the parent, in the code you
posted. popen, fork and other thinks in multi-threaded applications are
hairy to put it mildly, and I am not experienced enough with POSIX
threads to get this to work. I'm not sure if I need flockfile or
pthread_atfork or whatever.

That you're ignoring SIGPIPE is a hint something's wrong with the pipe
writers, a proper code cannot catch SIGPIPE here. I refined your code a
bit and used error detection all over the map and got short writes for
mails beyond 4096, and that it fails nondeterministically, is a hint
there is a race somewhere. Forking with streams that are in flux is
difficult, and I see literally dozens of pipe file descriptors in the
bogofilter processes, so I presume something's inconsistent.

The issue at hand is that the chunk size (think block size) you can
write to a pipe is limited, it appears to be 4096 on my Linux 2.6.9
machine.

If I use input redirection and throw out the shell, bogofilter works
properly. See the attached demonstration code "try.c" - it's not too
different from t.lock3 though.

To use:

1. generate a spam.eml file
2. compile the code:
   gcc -O -lpthread -o try try.c
3. run it:
   ./try

-- 
Matthias Andree
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: try.c
URL: <https://www.bogofilter.org/pipermail/bogofilter-dev/attachments/20041019/811248cc/attachment.c>


More information about the bogofilter-dev mailing list