]> git.sur5r.net Git - bacula/bacula/commitdiff
Put mutex around gethostbyname()
authorKern Sibbald <kern@sibbald.com>
Fri, 15 Nov 2002 22:18:44 +0000 (22:18 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 15 Nov 2002 22:18:44 +0000 (22:18 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@196 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/lib/bnet.c
bacula/src/version.h

index 709517b49903b60f633e42202c00e3ad544da842..a30cad250c769a09740c7dd6682c366f43ee3700 100644 (file)
@@ -16,8 +16,12 @@ Test:
 - blocksize recognition code.
 
 For 1.27 release:
+- Add ORDER BY JobId to list of Jobs in query.sql, and in
+  ua_list.c (list command).
+- Make gethostbyname() thread safe in bnet.c
 
 After 1.27
+- Check if both CatalogFiles and UseCatalog are set to SD.
 - Check if we can bump Bacula FD priorty in Win2000
 - Implement FileOptions.
 - Make bcopy read through bad tape records.
index f523179a91ba6fd5149d2d386a29fe107c3b51cf..e0620e2175944025ba7702a2c35f52a4f76e604e 100644 (file)
@@ -362,6 +362,8 @@ bnet_wait_data(BSOCK *bsock, int sec)
    }
 }
 
+static pthread_mutex_t ip_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 /*
  * Convert a hostname or dotted IP address into   
  * a s_addr.  We handle only IPv4.
@@ -379,16 +381,18 @@ static uint32_t *bget_host_ip(void *jcr, char *host)
       addr_list[0] = inaddr.s_addr;
       addr_list[1] = (uint32_t) -1;
    } else {
-      /******FIXME***** use gethostbyname_r or mutex ****/
+      P(ip_mutex);
       if ((hp = gethostbyname(host)) == NULL) {
          Jmsg2(jcr, M_ERROR, 0, "gethostbyname() for %s failed: ERR=%s\n", 
               host, strerror(errno));
+        V(ip_mutex);
         return NULL;
       }
       if (hp->h_length != sizeof(inaddr.s_addr) || hp->h_addrtype != AF_INET) {
-          Jmsg2(jcr, M_ERROR, 0, _("gethostbyname() network address length error.\n\
+         Jmsg2(jcr, M_ERROR, 0, _("gethostbyname() network address length error.\n\
 Wanted %d got %d bytes for s_addr.\n"), sizeof(inaddr.s_addr), hp->h_length);
-         return NULL;
+        V(ip_mutex);
+        return NULL;
       }
       i = 0;
       for (p = hp->h_addr_list; *p != 0; p++) {
@@ -401,6 +405,7 @@ Wanted %d got %d bytes for s_addr.\n"), sizeof(inaddr.s_addr), hp->h_length);
         addr_list[i++] = (*(struct in_addr **)p)->s_addr;
       }
       addr_list[i] = (uint32_t) -1;
+      V(ip_mutex);
    }
    return addr_list;
 }
index 9ef301fe814a995945ddfa81c777ff19cb4a98ab..08a29752cc6404a49c4cd576d2e51b6c08bf8515 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.27"
 #define VSTRING "1"
-#define DATE    "14 November 2002"
-#define LSMDATE "14Nov02"
+#define DATE    "15 November 2002"
+#define LSMDATE "15Nov02"
 
 /* Debug flags */
 #define DEBUG 1