Re: Memoryleak in SSL.Connection

Andre Reitz <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
On Mon, 5 Apr 2004 23:08:07 +0200
Andre Reitz <[email protected]> wrote:

> On Mon, 5 Apr 2004 22:36:37 +0800
> Ng Pheng Siong <[email protected]> wrote:
> 
> > On Thu, Apr 01, 2004 at 11:25:53PM +0200, Andre Reitz wrote:
> > > I am pretty sure, that since the Connection object
> > > gets garbage collected (and the __del__ method gets called)
> > > the server sometimes hangs completely.
> > > [...]
> > > IN OTHER WORDS:
> > > Is it possible that:
> > >    m2.bio_free(self.sslbio)
> > >    m2.bio_free(self.sockbio)
> > > or self.socket.close()
> > > may hang if the client does not finish the connection completely?
> >
> > Perhaps the server is waiting for SSL connection-close alerts, and
> > OpenSSL isn't allowing the session to be harvested?
> >
> > E.g., running echo.py, see the ALERTs at the end:
> >
> >   INFO: SSL connect: SSL negotiation finished successfully
> >   Host = vista.netmemetic.com
> >   Cipher = DHE-RSA-AES256-SHA
> >   Server = /C=SG/O=M2Crypto/CN=localhost/[email protected]
> >   ALERT: read: warning: close notify
> >   ALERT: write: warning: close notify
> >
> > Before your server calls self.socket.close(), try calling this:
> >
> >   self.socket.set_shutdown(SSL.SSL_SENT_SHUTDOWN|SSL.SSL_RECEIVED_SHUTDOWN)
> >
> Ok I will try it...
> 
> > This says to set the SSL 'shutdown' state to "sent shutdown" and "received
> > shutdown". The precise behaviour is described in the TLS RFC.
> >
> > Are your clients in Python?
> >
> yes. but the clients dont use M2Crypto.
> They use socket.ssl from the standard distribution.
> 
> 

now I have tried it: 
 calling 
    set_shutdown(SSL.SSL_SENT_SHUTDOWN|SSL.SSL_RECEIVED_SHUTDOWN)
 before destructor __del__ comes
 stops my multi-threaded server from hanging.

 if I do not call 
    set_shutdown(SSL.SSL_SENT_SHUTDOWN|SSL.SSL_RECEIVED_SHUTDOWN)
 the complete server sometimes hangs in 
   m2.bio_free(self.sslbio)  of Connection.__del__
 
Why?
  does bio_free still want to communicate with the client?
  (which is already disconnected?)


Thank you very much for your help.
Greetings, Andre'




> 
> >
> > --
> > Ng Pheng Siong <[email protected]>
> >
> > http://firewall.rulemaker.net -+- Firewall Change Management & Version Control
> > http://sandbox.rulemaker.net/ngps -+- Open Source Python Crypto & SSL


-- 
__________________________________________________________________________

Als Technologieunternehmen konzipieren und entwickeln wir maßgeschneiderte Feedback- und
Monitoring-Systeme - wie beispielsweise Lösungen für Beschwerde- und Ideenmanagement.
Mit dem Inquery® Survey Server bieten wir eine der leistungsfähigsten Standardlösungen für
Online-Umfragen mit dem Schwerpunkt auf der Messung von Kundenzufriedenheit an.
__________________________________________________________________________


Inworks GmbH
Andre Reitz, Leiter Entwicklung
Hörvelsinger Weg 39, 89081 Ulm, Germany
Tel +49 (0) 731 / 93807-21
Fax +49(0)731/93807-18
Internet: http://www.inworks.de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.