Tuesday, May 25, 2004

More on maildrop

I've learned a few more things since my last entry on this subject. First, the big problem:

19:03:15 up 8 days, 3:51, 0 users, load average: 101.54, 100.08, 87.97

Why O why? Well, flock didn't work for me. I don't know why. It would appear to work for a while, but as the maildrop processes built up, it would just break, and I'd have 50 virus scanners all running at once. Processes were dropping dead as my memory was exhausted. The solution was the use dotlock instead.

The other important tidbit I've picked up is that I can't really test the results of backquotes and expect to be testing the exit status of the command. It's testing whether it output any text (I guess). To test the exit status of a command, you have to look at the $RETURNCODE variable that's set after executing the command. In my earlier entry, I had code that looks like this:
    flock "$PROCLOCK" {

if ( `/usr/bin/clamscan --quiet --mbox -` )
to "| /usr/bin/tmda-filter -I $HOME/.tmda/filters/always_hold"
}

That now looks like this:
    dotlock "$PROCLOCK" {

`/usr/bin/clamscan --quiet --mbox -`
if ( $RETURNCODE != 0 )
to "| /usr/bin/tmda-filter -I $HOME/.tmda/filters/always_hold"
}

The good news is that Linux 2.6 stood up to this. It was very very slow, even when I was using a nice -15 root shell, but it survived, and it worked well enough for me to fix the problem while it was happening.

No comments: