]> sjero.net Git - wget/commitdiff
[svn] Network updates.
authorhniksic <devnull@localhost>
Mon, 10 Nov 2003 13:20:46 +0000 (05:20 -0800)
committerhniksic <devnull@localhost>
Mon, 10 Nov 2003 13:20:46 +0000 (05:20 -0800)
src/ChangeLog
src/connect.c
src/host.c
src/host.h

index 8fe7b7b7f31381f69b9b4c8be8cda28356119aad..99d0478d11acb9c581cc58e26c42c117a302e0ca 100644 (file)
@@ -1,3 +1,11 @@
+2003-11-10  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * connect.c (connect_to_host): Use that flag to decide whether to
+       re-resolve the host name.
+
+       * host.c (struct address_list): Added a flag that maintains
+       whether the connection worked at some point.
+
 2003-11-10  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * host.c (lookup_host): Special-case the numeric addresses only in
index 3ed03c71b5339f640aa7ee4a32fd2c12ca45d898..90729aec262970d41724bcc45683d01c66148d57 100644 (file)
@@ -356,12 +356,16 @@ connect_to_host (const char *host, int port)
     }
   address_list_release (al);
 
-  if (sock < 0 && address_list_cached_p (al))
+  if (sock >= 0)
+    /* Mark a successful connection to one of the addresses. */
+    address_list_set_connected (al);
+
+  if (sock < 0 && address_list_connected_p (al))
     {
-      /* We were unable to connect to any address in a list we've
-        obtained from cache.  There is a possibility that the host is
-        under dynamic DNS and has changed its address.  Resolve it
-        again.  */
+      /* We are unable to connect to any of HOST's addresses, although
+        we were previously able to connect to HOST.  That might
+        indicate that HOST is under dynamic DNS and the addresses
+        we're connecting to have expired.  Resolve it again.  */
       forget_host_lookup (host);
       goto again;
     }
@@ -649,6 +653,10 @@ struct extended_info {
   void *ctx;
 };
 
+/* Register the handlers for operations on FD.  This is meant
+   primarily for transport layers like SSL that piggyback on sockets,
+   but with their own readers, writers, etc.  */
+
 void
 register_extended (int fd, xreader_t reader, xwriter_t writer,
                   xpoller_t poller, xcloser_t closer, void *ctx)
index 131e14147343b318dadcdf04373cc029aa96c056..eb0897cdf20da455c641f8edec9d31085abb6dbc 100644 (file)
@@ -97,8 +97,9 @@ struct address_list {
   ip_address *addresses;       /* pointer to the string of addresses */
 
   int faulty;                  /* number of addresses known not to work. */
-  int from_cache;              /* whether this entry was pulled from
-                                  cache or freshly looked up. */
+  int connected;               /* whether we were able to connect to
+                                  one of the addresses in the list,
+                                  at least once. */
 
   int refcount;                        /* reference count; when it drops to
                                   0, the entry is freed. */
@@ -113,15 +114,6 @@ address_list_get_bounds (const struct address_list *al, int *start, int *end)
   *end   = al->count;
 }
 
-/* Return whether this address list entry has been obtained from the
-   cache.  */
-
-int
-address_list_cached_p (const struct address_list *al)
-{
-  return al->from_cache;
-}
-
 /* Return a pointer to the address at position POS.  */
 
 const ip_address *
@@ -191,6 +183,23 @@ address_list_set_faulty (struct address_list *al, int index)
     al->faulty = 0;
 }
 
+/* Set the "connected" flag to true.  This flag used by connect.c to
+   see if the host perhaps needs to be resolved again.  */
+
+void
+address_list_set_connected (struct address_list *al)
+{
+  al->connected = 1;
+}
+
+/* Return the value of the "connected" flag. */
+
+int
+address_list_connected_p (const struct address_list *al)
+{
+  return al->connected;
+}
+
 #ifdef ENABLE_IPV6
 /**
   * address_list_from_addrinfo
@@ -513,7 +522,6 @@ lookup_host (const char *host, int silent)
        {
          DEBUGP (("Found %s in host_name_addresses_map (%p)\n", host, al));
          ++al->refcount;
-         al->from_cache = 1;
          return al;
        }
     }
index 8666c08c7e05112c6dd024c284a66f888230774e..5029c9c24e21ef663a7a2c2a13df9860bfd03e34 100644 (file)
@@ -98,11 +98,12 @@ void forget_host_lookup PARAMS ((const char *));
 
 void address_list_get_bounds PARAMS ((const struct address_list *,
                                      int *, int *));
-int address_list_cached_p PARAMS ((const struct address_list *));
 const ip_address *address_list_address_at PARAMS ((const struct address_list *,
                                                   int));
 int address_list_find PARAMS ((const struct address_list *, const ip_address *));
 void address_list_set_faulty PARAMS ((struct address_list *, int));
+void address_list_set_connected PARAMS ((struct address_list *));
+int address_list_connected_p PARAMS ((const struct address_list *));
 void address_list_release PARAMS ((struct address_list *));
 
 const char *pretty_print_address PARAMS ((const ip_address *));