SF.net SVN: tmda: [2171] trunk/tmda/bin/tmda-ofmipd

[email protected] Tue, 06 Mar 2007 23:01:47 -0800
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Revision: 2171
          http://svn.sourceforge.net/tmda/?rev=2171&view=rev
Author:   srwarren
Date:     2007-03-06 23:01:47 -0800 (Tue, 06 Mar 2007)

Log Message:
-----------
tmda-ofmipd: Prevent 100% CPU usage when the client disconnects.

This can be reproduced by running the following command, waiting
for the SMTP server signon message, and typing QUIT<enter>.

openssl s_client -connect 127.0.0.1:8027 -crlf

This appears to be a bug in tlslite, because it continually calls
outReadEvent with an empty string.

The fix we apply here is probably the fix that should be applied
to tlslite itself. The fix is however applied to tmda-ofmipd in
order not to require a patched tlslite. Besides, the tlslite
TLSAsyncDispatcherMixIn is duplicated in tmda-ofmipd in order to
add features (STARTTLS support). Possibly, though, this fix should
be applied to the caller of outReadEvent so as to apply to all
tlslite users, not just the asyncore integration. Still, even if
the bug is fixed there, this fix here won't hurt anything.

Modified Paths:
--------------
    trunk/tmda/bin/tmda-ofmipd

Modified: trunk/tmda/bin/tmda-ofmipd
===================================================================
--- trunk/tmda/bin/tmda-ofmipd	2007-03-02 14:19:12 UTC (rev 2170)
+++ trunk/tmda/bin/tmda-ofmipd	2007-03-07 07:01:47 UTC (rev 2171)
@@ -479,8 +479,11 @@
         def outReadEvent(self, readBuffer):
             if not self._active:
                 raise "Internal state confusion"
-            self.readBuffer = readBuffer
-            self.siblingClass.handle_read(self)
+            if readBuffer == '':
+                self.outCloseEvent()
+            else:
+                self.readBuffer = readBuffer
+                self.siblingClass.handle_read(self)
 
         def outWriteEvent(self):
             if not self._active:


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.