]> mj.ucw.cz Git - pciutils.git/commitdiff
Call res_init() only once.
authorMartin Mares <mj@ucw.cz>
Wed, 13 Feb 2008 15:57:02 +0000 (16:57 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 13 Feb 2008 15:57:02 +0000 (16:57 +0100)
This avoids perpetual re-reading of /etc/resolv.conf.

lib/names-net.c

index 335bf682212495d1da20b35b1850ac6d5bb1a91f..d96cc4d83a9c79e6b93be8f7eb197f0f94a9d2a2 100644 (file)
@@ -21,6 +21,7 @@
 char
 *pci_id_net_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4)
 {
+  static int resolver_inited;
   char name[256], dnsname[256], txt[256], *domain;
   byte answer[4096];
   const byte *data;
@@ -61,7 +62,11 @@ char
   sprintf(dnsname, "%s.%s", name, domain);
 
   a->debug("Resolving %s\n", dnsname);
-  res_init();
+  if (!resolver_inited)
+    {
+      resolver_inited = 1;
+      res_init();
+    }
   res = res_query(dnsname, ns_c_in, ns_t_txt, answer, sizeof(answer));
   if (res < 0)
     {