---
smtp::sendmessage on localhost gives me the following error sometimes:
"SMTP error: read from server timed out"
on sendmail's side:
# tail -f /var/log/maillog
...
Oct 19 10:08:16 stats sendmail[19591]: k9J84Tsn019591:
localhost.localdomain [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN
during connection to MTA
...
That seems to happen on high CPU load (1 among 4 though) but works most
of the time.
---
I modified the tcllib smtp module code as follows:
---
proc echo {args} {foreach argument $args {puts -nonewline "$argument
"}; puts {}}
proc ::smtp::readable {token} {
# FRINK: nocheck
variable $token
upvar 0 $token state
if {[catch { array set options $state(options) }]} {
return
}
set state(line) ""
if {[catch { gets $state(sd) state(line) } result]} {
set state(readable) -2
echo set state(error) $result
set state(error) $result
} elseif {$result == -1} {
echo result == -1
if {[eof $state(sd)]} {
set state(readable) -3
echo set state(error) "premature end-of-file from server"
set state(error) "premature end-of-file from server"
}
} else {
echo $state(line)
# If the line ends in \r, remove the \r.
if {![string compare [string index $state(line) end] "\r"]} {
set state(line) [string range $state(line) 0 end-1]
}
set state(readable) 1
}
if {$state(readable) < 0} {
echo $state(readable) < 0
if {$options(-debug)} {
puts stderr " ... $state(error) ..."
flush stderr
}
catch { fileevent $state(sd) readable "" }
}
}
---
which gives:
---
Trying 127.0.0.1...
result == -1
result == -1
result == -1
result == -1
... (loops / 100% CPU)
---
Using strace (on Fedora Core 6 / 64 bits):
---
write(2, "Trying 127.0.0.1...", 19Trying 127.0.0.1...) = 19
write(2, "\n", 1
) = 1
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 53
fcntl(53, F_SETFD, FD_CLOEXEC) = 0
getsockopt(53, SOL_SOCKET, SO_SNDBUF, [227633283072], [4]) = 0
getsockopt(53, SOL_SOCKET, SO_RCVBUF, [227633354068], [4]) = 0
fcntl(53, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(53, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(53, {sa_family=AF_INET, sin_port=htons(25),
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now
in progress)
fcntl(53, F_GETFL) = 0x802 (flags
O_RDWR|O_NONBLOCK)
fcntl(53, F_SETFL, O_RDWR|O_NONBLOCK) = 0
select(54, [3 4 6 8 10 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43
45 47 49 51 53], [], [], {0, 843608}) = 1 (in [3], left {0, 843608})
recvfrom(3,
"0\201\223\2\1\0\4\6public\242\201\205\2\0045a`\354\2\1"..., 2048, 0,
{sa_family=AF_INET, sin_port=htons(161),
sin_addr=inet_addr("61.84.248.4")}, [16]) = 150
sendto(3, "0\201\201\2\1\0\4\6public\241t\2\0049\234Y\307\2\1\0\2"...,
132, 0, {sa_family=AF_INET, sin_port=htons(161),
sin_addr=inet_addr("61.84.248.4")}, 16) = 132
select(54, [3 4 6 8 10 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43
45 47 49 51 53], [], [], {1, 249921}) = 1 (in [53], left {1, 248000})
select(54, [], [21], [21], {0, 0}) = 0 (Timeout)
write(1, "result == -1 || \n", 17result == -1 ||
) = 17
select(54, [3 4 6 8 10 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43
45 47 49 51 53], [], [], {1, 248178}) = 1 (in [53], left {1, 248178})
select(54, [], [21], [21], {0, 0}) = 0 (Timeout)
write(1, "result == -1 || \n", 17result == -1 ||
) = 17
... (last 3 lines repeated indefinitely)
---
Note: socket 3 gets a SNMP reply in the middle, socket 53 is the SMTP
connection.
What more can I do to solve the problem?
Your help is really appreciated, as I need to get rid of that high CPU
usage, which can last for 30 minutes!
Many thanks in advance,
Jean-Luc