Subject: Bug#3190: rlogin takes far too long when remote says Connection Refused

From: Ian Jackson <[email-masked]>
Date: Sun, 2 Jun 96 23:49 BST

Package: netstd
Version: 2.03-1

-chiark:~> time rlogin myrddin -l ijackson
myrddin.chu.cam.ac.uk: Connection refused
Command had non-zero exit status 1
0.03user 0.01system 0:31.06elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (80major+27minor)pagefaults 0swaps
You have new mail in /usr/spool/mail/ian
-chiark:junk> time telnet myrddin login
Trying 131.111.131.23...
telnet: Unable to connect to remote host: Connection refused
Command had non-zero exit status 1
0.05user 0.01system 0:00.11elapsed 50%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (105major+37minor)pagefaults 0swaps
-chiark:~>

Using strace I can see that it appears to be retrying the call !

Ian.

---

From: "Peter Tobias" <[email-masked]>
Date: Mon, 3 Jun 1996 02:44:47 +0200 (MET DST)

> Using strace I can see that it appears to be retrying the call !

I'll reassign the bug to libc5. inet/rcmd.c from libc5 uses the
following code which is causing the delay:

if (errno == ECONNREFUSED && timo <= 16) {
        sleep(timo);
        timo *= 2;
        continue;
}

You'll see the same behaviour with every program that uses the rcmd
library function (telnet doesn't use rcmd).

BTW: This is probably more a feature than a bug.

Thanks,

Peter

--
 Peter Tobias                                EMail:
 Fachhochschule Ostfriesland                 [email-masked]
 Fachbereich Elektrotechnik und Informatik   [email-masked]
 Constantiaplatz 4, 26723 Emden, Germany

---

From: Mark Eichin <[email-masked]>
Date: 02 Jun 1996 21:30:23 -0400

> Using strace I can see that it appears to be retrying the call !

Hmm. From what I remember of the original BSD source, yes, it spins
(around a sleep, I think) trying to reconnect on a connection refused,
until an alarm goes off. There's probably some arcane bit of history
behind it... but it should probably just go away :-)

---

From: Miquel van Smoorenburg <[email-masked]>
Date: Mon, 3 Jun 1996 17:50:11 +0200 (MET DST)

> behind it... but it should probably just go away :-)

No, it is needed. Sometimes our login machine still thinks it has a socket
open to the terminal server, while there isn't a socket open on the
terminal server. Thus it can happen that the terminal server tries to
connect from a source port of which the login machine thinks it is already
in use. Result is ECONNREFUSED, and the code in the BSD source just
does a sleep and retries on another port number.

In fact that isn't really true; it doesn't work under Linux. I do have
a fix though.

open
--
  Miquel van    | Cistron Internet Services   --    Alphen aan den Rijn.
  Smoorenburg,  | mailto:[email-masked]          http://www.cistron.nl/
[email-masked] | Tel: +31-172-419445 (Voice) 430979 (Fax) 442580 (Data)

---

From: Ian Jackson <[email-masked]>
Date: Tue, 4 Jun 96 03:43 BST

(debian-bugs removed from the CC while we resolve this)

Miquel van Smoorenburg writes ("Re: Bug#3190: rlogin takes far too long when remote says Connection Refused"):
...
> does a sleep and retries on another port number.

This doesn't make sense to me.  Which end has what idea of which
connections are where ?

Even if you're right, I think there is some bug here that is being
worked around rather badly, surely ?

If you'd like to try to explain to me what's going on I'd be grateful.

Ian.