Subject: bug#30475: 25.3; connection-failure errors

From: Ken Raeburn <[email-masked]>
Date: Thu, 15 Feb 2018 17:24:32 -0500

I'm running on a network with a broken IPv6 setup; there are router
advertisements so I get a network address and default router, but the
router can't get anywhere so I always get "no route" errors back.

If I try running rcirc to connect to freenode, I sometimes get:

  Connecting to irc.freenode.net...
  open-network-stream: Failed connect: No route to host

If I retry a few times, eventually it succeeds. At the moment,
irc.freenode.net resolves to 5 IPv4 addresses and 3 IPv6
addresses. Emacs doesn't tell me which address it's trying each time,
but I expect something is doing randomization or round-robin ordering.

1) It might be useful (for debugging, at least) if the error message
indicated the host name and, when open-network-stream is given a host
name, the actual address tried that got the error, if we're not going to
try multiple addresses.

2) If a host has multiple addresses, routing failures (or timeouts, or
probably some other failures) should cause us to try the next
address. The error on one address should probably still be displayed so
it's saved to the *Messages* buffer, but success on a second address
when the first is unreachable should still let the application code go
forward.

2a) In fact, it wouldn't be completely insane to make "Happy Eyeballs"
(RFC 8305) style staggered but parallel connection attempts when both
IPv4 and IPv6 addresses are available.

In GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.19)
 of 2017-09-14 built on buildvm-31.phx2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.11906000
System Description:	Fedora release 27 (Twenty Seven)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no --with-xwidgets --with-modules
 build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu
 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Werror=format-security
 -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
 --param=ssp-buffer-size=4 -grecord-gcc-switches
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic'
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: rcirc

Minor modes in effect:
  buffer-face-mode: t
  diff-auto-refine-mode: t
  rcirc-track-minor-mode: t
  display-time-mode: t
  desktop-save-mode: t
  which-function-mode: t
  icomplete-mode: t
  global-hi-lock-mode: t
  hi-lock-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  use-hard-newlines: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Recent messages:
open-network-stream: Failed connect: No route to host
Connecting to irc.freenode.net...
open-network-stream: Failed connect: No route to host
Connecting to irc.freenode.net...done
Connecting to irc.devel.redhat.com...done
Quit
funcall-interactively: End of buffer
mwheel-scroll: Beginning of buffer [4 times]
Mark set
mwheel-scroll: Beginning of buffer

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message idna rfc822 mml mml-sec epg
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums add-log network-stream
nsm auth-source cl-seq eieio eieio-core cl-macs password-cache starttls
tls gnutls face-remap conf-mode js sgml-mode json map thingatpt
adaptive-wrap make-mode sh-script smie executable org-element org-rmail
org-mhe org-irc org-info org-gnus org-docview doc-view subr-x jka-compr
image-mode dired org-bibtex bibtex org-bbdb org-w3m org org-macro
org-footnote org-pcomplete pcomplete org-list org-faces org-entities
noutline outline org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-src ob-keys ob-comint comint ansi-color ob-core
ob-eval org-compat org-macs org-loaddefs format-spec find-func cal-menu
calendar cal-loaddefs cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs vc-git diff-mode rcirc gnus
gnus-ems nnheader gnus-util mail-utils mm-util help-fns mail-prsvr
wid-edit time desktop frameset cus-start cus-load kr-init iso-transl
advice smart-quotes easy-mmode time-date which-func imenu icomplete
server term disp-table ehelp ring hi-lock finder-inf info package
epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode
easymenu cconv cl-loaddefs pcase cl-lib mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 337704 14852)
 (symbols 48 36689 0)
 (miscs 40 2764 705)
 (strings 32 72872 11293)
 (string-bytes 1 2215683)
 (vectors 16 31204)
 (vector-slots 8 689180 7376)
 (floats 8 317 229)
 (intervals 56 9731 0)
 (buffers 976 87))