You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Alin Dobre <al...@gmail.com> on 2007/09/14 08:38:50 UTC

spamd weird socket handling

Hello everyone,

I'm using a mail server that integrates with spamassassin, by passing
the messages from the queue to the spamd daemon via the socket
(default 127.0.0.1:783) and takes various actions using spamd's
response.
Everything worked flawlessly for 99.99% of scanned messages, now some
messages cannot be scanned and spamd returns:

Sep 13 11:30:09 k9 spamd[27231]: spamd: timeout: (300 second timeout
while trying to CHECK) at /usr/bin/spamd line 2000, <GEN82> line 84.

I'm using spamassassin 3.2.3 (latest version) and the following lines
are being sent over socket:

'CHECK SPAMC/1.2\r\nContent-length: %d\r\n\r\n', size
and then the raw rfc822 message follows. The content-length size is
calculated correctly, so this cannot be the problem, otherwise spamd
would have returned an error regarding different content lengths.
Shortly, the algorithm is:
socket.send
socket.recv

After digging a while more deeply, I have found out that the spamc
client, after sending the message, shuts down writing on the socket
and spamd responds immediately. I did the same and it worked. In this
case the algo is:
socket.send
socket.shutdown(write)
socket.recv


My questions are:
- Why does it work for 99.99% of messages without having to shutdown
writing on socket
- Why doesn't it work with that message?
- If spamd depends on this shutdown, isn't the Content-length
specification redundant?

Here's an email that gets timed out when scanning:

$ ./send_message.py test-notok.eml
SPAMD/1.0 79 Timeout: (300 second timeout while trying to CHECK)

I have attached the python script as well as the test-notok.eml message.

Thanks in advance!

Regards,
Alin.