CONNECT_ERROR macro.
+2003-11-13 Hrvoje Niksic <hniksic@xemacs.org>
+
+ * http.c (gethttp): Ditto.
+
+ * ftp.c (getftp): Use retryable_socket_connect_error instead of
+ CONNECT_ERROR.
+
+ * wget.h (CONNECT_ERROR): Removed.
+
+ * connect.c (retryable_socket_connect_error): New function instead
+ of unsupported_socket_family_error.
+
2003-11-13 Hrvoje Niksic <hniksic@xemacs.org>
* wget.h (CONNECT_ERROR): Use it.
return 0;
}
-/* Return non-zero of the errno code passed to the function is a
- result of an attempt to create a socket of unsupported family. */
+/* Return non-zero if the error from the connect code can be
+ considered retryable. Wget normally retries after errors, but the
+ exception are the "unsupported protocol" type errors (possible on
+ IPv4/IPv6 dual family systems) and "connection refused". */
int
-unsupported_socket_family_error (int err)
+retryable_socket_connect_error (int err)
{
/* Have to guard against some of these values not being defined.
- Cannot use switch because some of the values might be equal. */
+ Cannot use a switch statement because some of the values might be
+ equal. */
+ if (0
#ifdef EAFNOSUPPORT
- if (err == EAFNOSUPPORT) return 1;
+ || err == EAFNOSUPPORT
#endif
#ifdef EPFNOSUPPORT
- if (err == EPFNOSUPPORT) return 1;
+ || err == EPFNOSUPPORT
#endif
#ifdef ESOCKTNOSUPPORT /* no, "sockt" is not a typo! */
- if (err == ESOCKTNOSUPPORT) return 1;
+ || err == ESOCKTNOSUPPORT
#endif
#ifdef EPROTONOSUPPORT
- if (err == EPROTONOSUPPORT) return 1;
+ || err == EPROTONOSUPPORT
#endif
#ifdef ENOPROTOOPT
- if (err == ENOPROTOOPT) return 1;
+ || err == ENOPROTOOPT
#endif
- /* Apparently, older versions of Linux used EINVAL instead of
- EAFNOSUPPORT. */
- if (err == EINVAL) return 1;
+ /* Apparently, older versions of Linux and BSD used EINVAL
+ instead of EAFNOSUPPORT and such. */
+ || err == EINVAL
+ )
+ return 0;
- return 0;
+ if (err == ECONNREFUSED && !opt.retry_connrefused)
+ return 0;
+
+ return 1;
}
#ifdef HAVE_SELECT
};
int socket_ip_address PARAMS ((int, ip_address *, int));
-int unsupported_socket_family_error PARAMS ((int));
+int retryable_socket_connect_error PARAMS ((int));
/* Flags for select_fd's WAIT_FOR argument. */
enum {
if (csock == E_HOST)
return HOSTERR;
else if (csock < 0)
- return CONNECT_ERROR (errno);
+ return (retryable_socket_connect_error (errno)
+ ? CONERROR : CONIMPOSSIBLE);
if (cmd & LEAVE_PENDING)
rbuf_initialize (&con->rbuf, csock);
logprintf (LOG_VERBOSE, _("couldn't connect to %s port %hu: %s\n"),
pretty_print_address (&passive_addr), passive_port,
strerror (save_errno));
- return CONNECT_ERROR (save_errno);
+ return (retryable_socket_connect_error (save_errno)
+ ? CONERROR : CONIMPOSSIBLE);
}
pasv_mode_open = 1; /* Flag to avoid accept port */
if (sock == E_HOST)
return HOSTERR;
else if (sock < 0)
- return CONNECT_ERROR (errno);
+ return (retryable_socket_connect_error (errno)
+ ? CONERROR : CONIMPOSSIBLE);
#ifdef HAVE_SSL
if (conn->scheme == SCHEME_HTTPS)
SSLERRCERTFILE,SSLERRCERTKEY,SSLERRCTXCREATE
} uerr_t;
-/* Whether the connection was unsuccessful or impossible. If the
- connection is considered impossible (e.g. for unsupported socket
- family errors), there is no sense in retrying. "Connection
- refused" is normally not retried, except when opt.retry_connrefused
- is specified. */
-
-#define CONNECT_ERROR(err) ((unsupported_socket_family_error (err) \
- || ((err) == ECONNREFUSED \
- && !opt.retry_connrefused)) \
- ? CONIMPOSSIBLE : CONERROR)
-
#endif /* WGET_H */