Opened 11 years ago

Closed 11 years ago

#19134 closed Cleanup/optimization (fixed)

Can't close SMTP connection, when already disconnected.

Reported by: Sebastian Noack Owned by: nobody
Component: Core (Mail) Version: 1.4
Severity: Normal Keywords:
Cc: hongshuning@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When the server has closed the SMTP connection (that happens rather quickly with most SMTP servers if you don't send any command for a few seconds), the exception SMTPServerDisconnected will be raised when trying to use the connection. That also happens when calling .quit(), like the SMTP backend does in its close() method.
So I have written a patch that catches SMTPServerDisconnected in addition to socket.sslerror, while closing the SMTP connection.

Attachments (2)

0001-Handle-SMTPServerDisconnected-in-EmailBackend.close.patch (1.1 KB ) - added by Sebastian Noack 11 years ago.
19134-with-test.diff (1.3 KB ) - added by Hong Shuning 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Claude Paroz, 11 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Thanks for the report. It would be nice to have a test for this. It's always a bit heary to simulate SMTP connections in the test suite, but I've been able to reproduce it with:

backend = smtp.EmailBackend()
backend.username = None # So as it does not try to login
backend.open()
SMTPBackendTests.server.stop()
backend.close()

by Hong Shuning, 11 years ago

Attachment: 19134-with-test.diff added

comment:2 by Hong Shuning, 11 years ago

I write the test case according to claudep's suggest.

comment:3 by Hong Shuning, 11 years ago

Cc: hongshuning@… added
Easy pickings: set
Needs tests: unset

comment:4 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 4081042ef51c0e679c78f2d0d13514af3434ed13:

[1.5.x] Fixed #19134 -- Allowed closing smtp backend when the server is stopped

Thanks Sebastian Noack for the report and the initial patch.
Backport of 1b3f832ab7 from master.

Note: See TracTickets for help on using tickets.
Back to Top