View | Details | Raw Unified | Return to bug 1076 | Differences between
and this patch

Collapse All | Expand All

(-)channels.c (-8 / +17 lines)
Lines 1226-1231 port_open_helper(Channel *c, char *rtype Link Here
1226
	xfree(remote_ipaddr);
1226
	xfree(remote_ipaddr);
1227
}
1227
}
1228
1228
1229
static void
1230
channel_set_reuseaddr(int fd)
1231
{
1232
	int on = 1;
1233
1234
	/*
1235
	 * Set socket options.
1236
	 * Allow local port reuse in TIME_WAIT.
1237
	 */
1238
	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1)
1239
		error("setsockopt SO_REUSEADDR fd %d: %s", fd, strerror(errno));
1240
}
1241
1229
/*
1242
/*
1230
 * This socket is listening for connections to a forwarded TCP/IP port.
1243
 * This socket is listening for connections to a forwarded TCP/IP port.
1231
 */
1244
 */
Lines 2182-2188 channel_setup_fwd_listener(int type, con Link Here
2182
    const char *host_to_connect, u_short port_to_connect, int gateway_ports)
2195
    const char *host_to_connect, u_short port_to_connect, int gateway_ports)
2183
{
2196
{
2184
	Channel *c;
2197
	Channel *c;
2185
	int sock, r, success = 0, on = 1, wildcard = 0, is_client;
2198
	int sock, r, success = 0, wildcard = 0, is_client;
2186
	struct addrinfo hints, *ai, *aitop;
2199
	struct addrinfo hints, *ai, *aitop;
2187
	const char *host, *addr;
2200
	const char *host, *addr;
2188
	char ntop[NI_MAXHOST], strport[NI_MAXSERV];
2201
	char ntop[NI_MAXHOST], strport[NI_MAXSERV];
Lines 2269-2281 channel_setup_fwd_listener(int type, con Link Here
2269
			verbose("socket: %.100s", strerror(errno));
2282
			verbose("socket: %.100s", strerror(errno));
2270
			continue;
2283
			continue;
2271
		}
2284
		}
2272
		/*
2285
2273
		 * Set socket options.
2286
		channel_set_reuseaddr(sock);
2274
		 * Allow local port reuse in TIME_WAIT.
2275
		 */
2276
		if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on,
2277
		    sizeof(on)) == -1)
2278
			error("setsockopt SO_REUSEADDR: %s", strerror(errno));
2279
2287
2280
		debug("Local forwarding listening on %s port %s.", ntop, strport);
2288
		debug("Local forwarding listening on %s port %s.", ntop, strport);
2281
2289
Lines 2682-2687 x11_create_display_inet(int x11_display_ Link Here
2682
				freeaddrinfo(aitop);
2690
				freeaddrinfo(aitop);
2683
				return -1;
2691
				return -1;
2684
			}
2692
			}
2693
			channel_set_reuseaddr(sock);
2685
			if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2694
			if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2686
				debug2("bind port %d: %.100s", port, strerror(errno));
2695
				debug2("bind port %d: %.100s", port, strerror(errno));
2687
				close(sock);
2696
				close(sock);

Return to bug 1076