]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/tls.c
Fix get_basename() -- rewrite
[bacula/bacula] / bacula / src / lib / tls.c
index e67f75818eee1b0de3b24698260b106d1d5ef869..fc447c2eb9513ae6b36dbb02610ab184eede352c 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -472,6 +472,7 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server)
    /* start timer */
    bsock->timer_start = watchdog_time;
    bsock->clear_timed_out();
+   bsock->set_killable(false);
 
    for (;;) { 
       if (server) {
@@ -525,6 +526,7 @@ cleanup:
    bsock->restore_blocking(flags);
    /* Clear timer */
    bsock->timer_start = 0;
+   bsock->set_killable(true);
 
    return stat;
 }
@@ -618,6 +620,7 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b
    /* start timer */
    bsock->timer_start = watchdog_time;
    bsock->clear_timed_out();
+   bsock->set_killable(false);
 
    nleft = nbytes;
 
@@ -637,6 +640,19 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b
          }
          break;
 
+      case SSL_ERROR_SYSCALL:
+         if (nwritten == -1) {
+            if (errno == EINTR) {
+               continue;
+            }
+            if (errno == EAGAIN) {
+               bmicrosleep(0, 20000); /* try again in 20 ms */
+               continue;
+            }
+         }
+         openssl_post_errors(bsock->get_jcr(), M_FATAL, _("TLS read/write failure."));
+         goto cleanup;
+
       case SSL_ERROR_WANT_READ:
          /* If we timeout on a select, this will be unset */
          FD_SET((unsigned)bsock->m_fd, &fdset);
@@ -681,6 +697,7 @@ cleanup:
 
    /* Clear timer */
    bsock->timer_start = 0;
+   bsock->set_killable(true);
    return nbytes - nleft;
 }