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