GNOME Bugzilla – Bug 653618
Sending email doesn't disconnect from a server
Last modified: 2013-09-13 09:21:52 UTC
Moving this from a downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=717386 Since I updated my system to Rawhide (and hence Evo 3.1.2), nearly every time I send an email, I get two failures (and have to hit 'Try Again') before it succeeds: "The reported error was "MAIL FROM command failed: mail.happyassassin.net Error: timeout exceeded"." and then: "The reported error was "MAIL FROM command failed: Connection reset by peer"." I suspect what's happening is Evo is not correctly closing the connection to the server after it sends a mail, so the next time you try to send a mail it tries to re-use the still-open connection from the last time you sent a mail, and this fails. The server in question is my own personal server, which is Postfix running on a Mandriva 2011 VM. It may be that I could configure my server somehow to allow the behaviour Evo is trying, but I consider it a bug that Evo regressed from working correctly with my SMTP server configuration in 3.0 to failing like this in 3.1, especially since I can't seem to find any preference to control this behaviour. I can grab logs from the server end if that would help. (The new 'IMAP+' protocol seems to have similar issues with my IMAP server, courier-imap running on the same box; if I use it instead of the 'IMAP' protocol, I get errors about exceeding the maximum number of simultaneous connections or something like that.)
Confirming, I noticed similar behaviour earlier too, but sometimes not so often. The idea about not closed connection is correct. All this happened after the transports were also cached in the evolution. The stable version disconnects from the server on the transport unref in > mail_session_send_to_thread (simple=0x2f76520, session=0x18ef1b0, > cancellable=0x7fb844019600) at e-mail-session-utils.c:430 but the git master doesn't unref the transport, neither frees it, thus it's kept connected till server disconnects on its own, which breaks sending of the next message.
Created attachment 190909 [details] [review] evo patch for evolution; Disconnect when was connecting during message sending.
Created commit 28bd28a in evo master (3.1.3+)
Looks good with the patch at first glance - I see a proper disconnect from Evo in my SMTP server log. Will monitor and confirm this resolves the issue.
Strangely enough, the same bug recurred in 3.8.5. I checked on the code and the patch is implmeneted, so I'm completely at a loss what the reason may be. I experienced the same behavior with two difference SMTP servers.
On my own server, I was able to fix the problem by setting smtp_connection_cache_time_limit = 10s in /etc/postfix/main.cf; however, this is not a universal solution to the issue.
Is it possible the connection left opened only on the server side? I'm testing this and I cannot reproduce it with lsof. I use command: $ lsof -p `pidof evolution` | grep smtp or, instead of smtp, part of the host time the SMTP connects to, and I see a new opened file being opened during sending, but once the send it over, both with an error or with success, the opened file is closed immediately after the operation is over.
I've started experimenting, but I found the bug difficult to reproduce. On one reboot of the server, everything works fine, on another, the bug is back. As this is my "production" mail server, I'll try to reproduce it on a backup server and report my findings.