SMTPDirect doesn't use persistent SMTP connections

Bug #558059 reported by jcea
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman
Fix Released
Undecided
Unassigned

Bug Description

Mailman 2.1.1 here.

"/Mailman/Handlers/SMTPDirect.py" is suppose to reuse
SMTP connections up to
"mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION" different
messages.

Nevertheless, it's NOT the case: "SMTPDirect" drop the
connection when send each message. This is an important
CPU hog when mailman has a long queue spool.

Here is the patch (sorry, I can't send it as an attach,
shame on me). It's fairly trivial :

>>>>>

Index: SMTPDirect.py
===================================================================
RCS file:
/opt/src/cvsroot/mailman/Mailman/Handlers/SMTPDirect.py,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.2.1
diff -u -u -r1.1.1.5 -r1.1.1.5.2.1
--- SMTPDirect.py 2003/03/20 10:14:58 1.1.1.5
+++ SMTPDirect.py 2003/03/21 16:48:31 1.1.1.5.2.1
@@ -48,7 +48,7 @@

 # Manage a connection to the SMTP server
-class Connection:
+class ConnectionClass:
     def __init__(self):
         self.__connect()

@@ -79,7 +79,15 @@
     def quit(self):
         self.__conn.quit()

+ def rset(self) :
+ self.__conn.rset()

+ def __del__(self) :
+ self.quit()
+
+
+Connection=ConnectionClass()
+

 def process(mlist, msg, msgdata):
     recips = msgdata.get('recips')
@@ -130,7 +138,7 @@
     # This means at worst, the last chunk for which
delivery was attempted
     # could get duplicates but not every one, and no
recips should miss the
     # message.
- conn = Connection()
+ conn = Connection
     try:
         msgdata['undelivered'] = chunks
         while chunks:
@@ -147,7 +155,8 @@
                 raise
         del msgdata['undelivered']
     finally:
- conn.quit()
+ conn.rset()
+ # conn.quit()
         msgdata['recips'] = origrecips
     # Log the successful post
     t1 = time.time()

<<<<<

Revision history for this message
jcea (jcea-users-sf) wrote :

Logged In: YES
user_id=97460

The proposed patch causes exceptions if space between
messages is greater than SMTP timeout.

Corrected patch (I still can't attach a file):

>>>>>

Index: SMTPDirect.py
===================================================================
RCS file:
/opt/src/cvsroot/mailman/Mailman/Handlers/SMTPDirect.py,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.2.3
diff -u -r1.1.1.5 -r1.1.1.5.2.3
--- SMTPDirect.py 2003/03/20 10:14:58 1.1.1.5
+++ SMTPDirect.py 2003/03/24 07:11:32 1.1.1.5.2.3
@@ -48,7 +48,7 @@

 # Manage a connection to the SMTP server
-class Connection:
+class ConnectionClass:
     def __init__(self):
         self.__connect()

@@ -58,6 +58,15 @@
         self.__numsessions =
mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION

     def sendmail(self, envsender, recips, msgtext):
+ try :
+ self.__conn.rset()
+ except :
+ try :
+ self.__conn.quit()
+ except :
+ pass
+ self.__connect()
+
         try:
             results = self.__conn.sendmail(envsender,
recips, msgtext)
         except smtplib.SMTPException:
@@ -79,6 +88,11 @@
     def quit(self):
         self.__conn.quit()

+ def __del__(self) :
+ self.quit()
+
+
+Connection=ConnectionClass()

 def process(mlist, msg, msgdata):
@@ -130,7 +144,7 @@
     # This means at worst, the last chunk for which
delivery was attempted
     # could get duplicates but not every one, and no recips
should miss the
     # message.
- conn = Connection()
+ conn = Connection
     try:
         msgdata['undelivered'] = chunks
         while chunks:
@@ -147,7 +161,7 @@
                 raise
         del msgdata['undelivered']
     finally:
- conn.quit()
+ # conn.quit()
         msgdata['recips'] = origrecips
     # Log the successful post
     t1 = time.time()

<<<<<

Revision history for this message
bwarsaw (bwarsaw) wrote :

Logged In: YES
user_id=12800

I implemented this differently. The fix will be part of
Mailman 2.1.2. If you are able, can you check the cvs
snapshot as of 19-Apr-2003?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.