]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bnet.c
Remove SQLite2 scripts
[bacula/bacula] / bacula / src / lib / bnet.c
index 163e172a00c989c5397a902abb3b1be5e3fccf92..f1d2dad151a814b12e905b8bfcb3295cfb9b4af6 100644 (file)
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
@@ -41,8 +41,6 @@
 #include "jcr.h"
 #include <netdb.h>
 
-extern time_t watchdog_time;
-
 #ifndef   INADDR_NONE
 #define   INADDR_NONE    -1
 #endif
@@ -88,7 +86,7 @@ int32_t read_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
             continue;
          }
          if (errno == EAGAIN) {
-            bmicrosleep(0, 200000);  /* try again in 200ms */
+            bmicrosleep(0, 20000);  /* try again in 20ms */
             continue;
          }
       }
@@ -151,7 +149,7 @@ int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
 
          FD_ZERO(&fdset);
          FD_SET((unsigned)bsock->m_fd, &fdset);
-         tv.tv_sec = 10;
+         tv.tv_sec = 1;
          tv.tv_usec = 0;
          select(bsock->m_fd + 1, NULL, &fdset, NULL, &tv);
          continue;
@@ -194,7 +192,7 @@ int32_t bnet_recv(BSOCK * bsock)
  */
 bool is_bnet_stop(BSOCK * bsock)
 {
-   return bsock->errors || bsock->is_terminated();
+   return bsock->is_stop();
 }
 
 /*
@@ -202,8 +200,7 @@ bool is_bnet_stop(BSOCK * bsock)
  */
 int is_bnet_error(BSOCK * bsock)
 {
-   errno = bsock->b_errno;
-   return bsock->errors;
+   return bsock->is_error();
 }
 
 /*
@@ -497,13 +494,16 @@ dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr)
             return 0;
          }
       } else {
-         errmsg = resolv_host(AF_INET, host, addr_list);
 #ifdef HAVE_IPV6
-         if (errmsg) {
-            errmsg = resolv_host(AF_INET6, host, addr_list);
-         }
+         /* We try to resolv host for ipv6 and ipv4, the connection procedure
+          * will try to reach the host for each protocols. We report only "Host
+          * not found" ipv4 message (no need to have ipv6 and ipv4 messages).
+          */
+         resolv_host(AF_INET6, host, addr_list);
 #endif
-         if (errmsg) {
+         errmsg = resolv_host(AF_INET, host, addr_list);
+
+         if (addr_list->size() == 0) {
             *errstr = errmsg;
             free_addresses(addr_list);
             return 0;
@@ -689,7 +689,7 @@ BSOCK *init_bsock(JCR * jcr, int sockfd, const char *who, const char *host, int
    return bsock;
 }
 
-BSOCK *dup_bsock(BSOCK * osock)
+BSOCK *dup_bsock(BSOCK *osock)
 {
    BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
    memcpy(bsock, osock, sizeof(BSOCK));
@@ -701,6 +701,9 @@ BSOCK *dup_bsock(BSOCK * osock)
    if (osock->host()) {
       bsock->set_host(bstrdup(osock->host()));
    }
+   if (osock->src_addr) {
+      bsock->src_addr = New( IPADDR( *(osock->src_addr)) );
+   }
    bsock->set_duped();
    return bsock;
 }