[gnu.emacs.bug] 18.53 fails to close socket on 'unreachable host' error

merlyn@intelob.intel.com (Randal L. Schwartz) (04/01/89)

In 18.53, process.c, near line 1118, lies the following text:

------------------------------
  s = socket (host_info->h_addrtype, SOCK_STREAM, 0);
  if (s < 0) 
    report_file_error ("error creating socket", Fcons (name, Qnil));

  if (connect (s, &address, sizeof address) == -1)
    error ("Host \"%s\" not responding", XSTRING (host)->data);
------------------------------

If the connect fails, the filedes 's' is not reclaimed with a
'close(s)'.  Eventually, you will run out of file descriptors (as I
did when scanning for hosts that support a particular server).  Fix:
add close(s) under that last if (curly braced, of course) before the
error() call.

/=====Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095========\
{        on contract to BiiN (for now :-) Hillsboro, Oregon, USA.             }
{<@intel-iwarp.arpa:merlyn@intelob.intel.com> ...!uunet!tektronix!biin!merlyn }
\=====Cute quote: "Welcome to Oregon... home of the California Raisins!"======/