+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
}
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;
}
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)
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. */
*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 *
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
{
DEBUGP (("Found %s in host_name_addresses_map (%p)\n", host, al));
++al->refcount;
- al->from_cache = 1;
return al;
}
}
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 *));