sjmudd / rpms / bacula

Forked from rpms/bacula 3 years ago
Clone
b41752e
b41752e
This patch should fix the spurious connection drops that fail jobs
b41752e
as reported in bug #888.
b41752e
Apply it to version 2.0.3 (possibly earlier versions of 2.0) with:
b41752e
b41752e
  cd <bacula-source>
b41752e
  patch -p0 <2.0.3-tls-disconnect.patch
b41752e
  make
b41752e
  ...
b41752e
  make install
b41752e
b41752e
Index: src/lib/tls.c
b41752e
===================================================================
b41752e
--- src/lib/tls.c	(revision 4668)
b41752e
+++ src/lib/tls.c	(working copy)
b41752e
@@ -540,14 +540,6 @@
b41752e
     * The first time to initiate the shutdown handshake, and the second to
b41752e
     * receive the peer's reply.
b41752e
     *
b41752e
-    * However, it is valid to close the SSL connection after the initial
b41752e
-    * shutdown notification is sent to the peer, without waiting for the
b41752e
-    * peer's reply, as long as you do not plan to re-use that particular
b41752e
-    * SSL connection object.
b41752e
-    *
b41752e
-    * Because we do not re-use SSL connection objects, I do not bother
b41752e
-    * calling SSL_shutdown a second time.
b41752e
-    *
b41752e
     * In addition, if the underlying socket is blocking, SSL_shutdown()
b41752e
     * will not return until the current stage of the shutdown process has
b41752e
     * completed or an error has occured. By setting the socket blocking
b41752e
@@ -560,6 +552,10 @@
b41752e
    flags = bnet_set_blocking(bsock);
b41752e
 
b41752e
    err = SSL_shutdown(bsock->tls->openssl);
b41752e
+   if (err == 0) {
b41752e
+      /* Finish up the closing */
b41752e
+      err = SSL_shutdown(bsock->tls->openssl);
b41752e
+   }
b41752e
 
b41752e
    switch (SSL_get_error(bsock->tls->openssl, err)) {
b41752e
       case SSL_ERROR_NONE:
b41752e
@@ -574,8 +570,6 @@
b41752e
          break;
b41752e
    }
b41752e
 
b41752e
-   /* Restore saved flags */
b41752e
-   bnet_restore_blocking(bsock, flags);
b41752e
 }
b41752e
 
b41752e
 /* Does all the manual labor for tls_bsock_readn() and tls_bsock_writen() */