By any other named
John C. Noble
jcn at aplvax.UUCP
Thu Jan 29 04:58:23 AEST 1987
References:
We have recently installed 4.3BSD on our Vax 11/780. We are running
with the gethostnamadr.c in /usr/src/lib/libc/named. However, we are
not running the nameserver daemon. In that case, gethostname() should
use /etc/hosts to get host names.
Inspection of gethostname() in gethostnamadr.c shows that
if (hp == NULL && errno == ECONNREFUSED)
hp = _gethtbyname(name);
(_gethtbyname() uses /etc/hosts to resolve 'name'.)
The variable hp should be NULL at this point if the nameserver is
not present. However, I discovered that occasionally errno is set
to ETIMEDOUT rather than ECONNREFUSED. In this case, /etc/hosts is
not queried, and the gethostname() call fails.
The variable errno is checked when hp == NULL since if the nameserver
is present, and the name is not found by the nameserver, then hp will
be NULL; but in this case we do not want to query /etc/hosts.
When gethostname() failed, errno was set to ETIMEDOUT at the time the
code segment in question was executed. According to INTRO(2), this
means "A connect or send request failed because the connected party did
not properly respond after a period of time". It is interesting
to note that ECONNREFUSED is described as "No connection could be made
because the target machine actively refused it". It seems to me that
ETIMEDOUT is a passive refusal, while ECONNREFUSED is an active refusal.
So, I think the proper "fix" is:
if (hp == NULL && (errno == ECONNREFUSED || errno == ETIMEDOUT))
hp = _gethtbyname(name);
This handles active and passive connect refusals from the nameserver.
Should it be possible to receive ETIMEDOUT errors if the nameserver
is not present? Note that we were received ECONNREFUSED errors most
of the time; only occasionally did we receive ETIMEDOUT errors.
Comments?
--
John Noble
JHU/APL
jcn at aplvax
More information about the Comp.unix.wizards
mailing list