Can bogofilter run by multiprocess at the same time

Matthias Andree matthias.andree at gmx.de
Thu Oct 14 00:46:40 CEST 2004


On Wed, 13 Oct 2004, 陈治璋 wrote:

> > Does it produce an actual deadlock or just make slow progress?
> It's an actual deadlock. There are many bogofilter processes and they
> process id remains the same for ever.

A deadlock is when process A has locked resource R and waits for
resource S while process B has locked resource S and waits for resource
R. I managed to trigger a "hang" on Linux, which turned out to be
processes waiting for input, which is why I don't attribute the hang to
bogofilter but rather the environment.

I didn't have the time to retry your code with fork() yet.

> Yes, I'm using glibc 2.1 in Linux. But in Solaris 2.8, I tested it again
> by replacing the following function and it blocks:
> 
> void* bogo_check(void* p)
> {
>                                                                                 
>    for(int i = 0; i < 10000; i ++){
>       const char* s_email = "ham.eml";
>       if (i%2){
>          s_email= "spam.eml";
>       }
>       string email = get_email(s_email);
>       FILE* file = popen("bogofilter", "w");
>       signal(SIGPIPE,   SIG_IGN);

This for instance is bogus, it masks a crashed child.

I'm not sure off-hand if the C++ string class is thread-safe.

> And it blocks at vfork().

Which vfork()? The original code you posted used POSIX threads.

BTW, vfork works only if the child process immediately
calls execve() or _exit(). If it does anything else, you must use fork.

-- 
Matthias Andree

Encrypted mail welcome: my GnuPG key ID is 0x052E7D95 (PGP/MIME preferred)



More information about the bogofilter-dev mailing list