﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
258	allocate_tcp_port sometimes returns in-use port	Brian Warner		"I've noticed intermittent unit test failures (in foolscap and in tahoe, which uses the same code) in which the port number returned by `allocate_tcp_port()` causes an EADDRINUSE when actually used to listen.

I did some quick experiments, but I still don't entirely understand what's going on. I know one issue is that `allocate_tcp_port()` binds the port to 127.0.0.1, and it seems like some operating systems will give us a port that someone else is already listening on (but bound to 0.0.0.0). It feels a bit like a kernel bug: it's comparing the interface identifiers and concluding that they don't overlap, when in fact 0.0.0.0 overlaps with everything.

But I'm pretty sure that's not the only failure mode. I think I tried changing our function to bind to 0.0.0.0, and there were other ports that got returned incorrectly. Also I think it behaves differently on linux and OS-X.

It's a rare failure, as there are only a handful of ports in use by other processes, and the kernel allocation uses a range of at least 10000 port numbers. But it's a drag to re-run the tests each time it happens.
"	defect	closed	major	0.12.3	network	0.12.2	fixed		
