]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bnet.c
Fix typo.
[bacula/bacula] / bacula / src / lib / bnet.c
index 9cc236998c382e0d1fd2c1fb8c8384b4e7215a10..49fda5b144cbbd54312d950cd4998be342103351 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.
@@ -86,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;
          }
       }
@@ -149,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;
@@ -192,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();
 }
 
 /*
@@ -200,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();
 }
 
 /*
@@ -495,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;
@@ -650,8 +652,10 @@ const char *bnet_sig_to_ascii(BSOCK * bs)
       return "BNET_HEARTBEAT";
    case BNET_HB_RESPONSE:
       return "BNET_HB_RESPONSE";
-   case BNET_PROMPT:
-      return "BNET_PROMPT";
+   case BNET_SUB_PROMPT:
+      return "BNET_SUB_PROMPT";
+   case BNET_TEXT_INPUT:
+      return "BNET_TEXT_INPUT";
    default:
       sprintf(buf, _("Unknown sig %d"), (int)bs->msglen);
       return buf;
@@ -699,6 +703,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;
 }