[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [PATCH] disable keep alive connections when using SSL
From:       Matthias Welwarsky <matze () stud ! fbi ! fh-darmstadt ! de>
Date:       2002-03-30 15:30:45
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

there seems to be a bug in openssl so that it returns "ok" when you call 
SSL_write() on a socket closed by the remote host. This breaks http POST 
requests when using keep alive connections.

This patch disables the keep alive when SSL is in use.
ok to commit?

regards,
	Matze

- -- 
Matthias Welwarsky
Fachschaft Informatik FH Darmstadt
Email: matze@stud.fbi.fh-darmstadt.de

"all software sucks equally, but some software is more equal"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8pdopANO+fpRuZ2IRAvsrAJ969MpklIBSEnnQ89VJqevZ28QkIgCgkLoK
Pt8FvIQB2U22L5CRuNTFrb0=
=bUhz
-----END PGP SIGNATURE-----

["http.cc.patch" (text/x-diff)]

? http.cc.patch
Index: http.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.cc,v
retrieving revision 1.470
diff -u -3 -p -r1.470 http.cc
--- http.cc	2002/03/23 04:26:55	1.470
+++ http.cc	2002/03/30 15:30:31
@@ -1415,6 +1415,8 @@ ssize_t HTTPProtocol::write (const void 
   {
     int n = TCPSlaveBase::write(buf, nbytes);
 
+    kdDebug(7113) << "(" << m_pid << ") TCPSlaveBase::write() returned " << n << endl;
+
     if ( n <= 0 )
     {
       // remote side closed connection ?
@@ -2106,9 +2108,10 @@ bool HTTPProtocol::httpOpen()
     kdDebug(7103) << "(" << m_pid << ") " << (*it) << endl;
 
   // now that we have our formatted header, let's send it!
-  bool sendOk;
+  int sendOk;
   sendOk = (write(header.latin1(), header.length()) == (ssize_t) header.length());
-  if (!sendOk)
+  kdDebug(7113) << "(" << m_pid << ") sendOk == " << sendOk << endl;
+  if (sendOk <= 0)
   {
     kdDebug(7113) << "(" << m_pid << ") httpOpen: Connection broken! ("
                   << m_state.hostname << ")" << endl;
@@ -2121,7 +2124,7 @@ bool HTTPProtocol::httpOpen()
           return false;
        sendOk = (write(header.latin1(), header.length()) == (ssize_t) header.length());
     }
-    if (!sendOk)
+    if (sendOk <= 0)
     {
        kdDebug(7113) << "(" << m_pid << ") httpOpen: sendOk==false. Connnection"
                         " broken ! " << endl;
@@ -2308,6 +2311,10 @@ bool HTTPProtocol::readHeader()
           m_bKeepAlive = true; // HTTP 1.1 has persistant connections.
       }
 
+      // work around possible bug in openssl
+      if (m_bIsSSL)
+	  m_bKeepAlive = false;
+
       if ( m_responseCode )
         m_prevResponseCode = m_responseCode;
 
@@ -2660,7 +2667,8 @@ bool HTTPProtocol::readHeader()
         if (strncasecmp(trimLead(buf + 11), "Close", 5) == 0) {
           m_bKeepAlive = false;
         } else if (strncasecmp(trimLead(buf + 11), "Keep-Alive", 10)==0) {
-          m_bKeepAlive = true;
+          if (!m_bIsSSL) 
+	      m_bKeepAlive = true;
         }
 
       }
@@ -3106,8 +3114,8 @@ bool HTTPProtocol::sendBody( bool dataIn
   infoMessage( i18n( "Sending data to <b>%1</b>" ).arg( m_request.hostname ) );
 
   // Send the content length...
-  bool sendOk = (write(c_buffer, strlen(c_buffer)) == (ssize_t) strlen(c_buffer));
-  if (!sendOk)
+  int sendOk = (write(c_buffer, strlen(c_buffer)) == (ssize_t) strlen(c_buffer));
+  if (sendOk <= 0)
   {
     kdDebug(7113) << "(" << m_pid << ") Connection broken when sending content length: ("
                   << m_state.hostname << ")" << endl;
@@ -3118,7 +3126,7 @@ bool HTTPProtocol::sendBody( bool dataIn
   // Send the data...
   //kdDebug() << "POST DATA: " << QCString(m_bufPOST) << endl;
   sendOk = (write(m_bufPOST.data(), m_bufPOST.size()) == (ssize_t) m_bufPOST.size());
-  if (!sendOk)
+  if (sendOk <= 0)
   {
     kdDebug(7113) << "(" << m_pid << ") Connection broken when sending message body: ("
                   << m_state.hostname << ")" << endl;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic