Subject: Re: open_network_connection patch

From: Pavel Curtis <[email-masked]>
Date: Wed, 13 Jan 1993 17:08:30 -0800

> Could I please have your patch to o_n_c?

The following patch, for version 1.7.0 of the server, should limit to 5 seconds
the amount of time that the server hangs waiting for an outbound network
connection to complete.  If it times out, then E_INVARG is raised.

The file is net_bsd_tcp.c; at the beginning of the definition of the function
`proto_open_connection', replace the line
	    int		s;
with the line
	    int		s, result;

Later in that same function, replace the line
	    if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
with the following lines:
	    id = set_timer(5, name_server_timeout, 0);
	    TRY
		result = connect(s, (struct sockaddr *) &addr, sizeof(addr));
		cancel_timer(id);
	    EXCEPT (ns_timeout)
		result = -1;
		errno = ETIMEDOUT;
		reenable_timers();
	    ENDTRY

	    if (result < 0) {