Avoid reusing auto-allocated ports after connection close.
This commit is contained in:
parent
2ac7694c3e
commit
d5735c631c
|
@ -160,11 +160,12 @@ tcp_dump_flags ( struct tcp_connection *tcp, unsigned int flags ) {
|
||||||
*/
|
*/
|
||||||
static int tcp_bind ( struct tcp_connection *tcp, unsigned int port ) {
|
static int tcp_bind ( struct tcp_connection *tcp, unsigned int port ) {
|
||||||
struct tcp_connection *existing;
|
struct tcp_connection *existing;
|
||||||
static uint16_t try_port = 1024;
|
static uint16_t try_port = 1023;
|
||||||
|
|
||||||
/* If no port specified, find the first available port */
|
/* If no port specified, find the first available port */
|
||||||
if ( ! port ) {
|
if ( ! port ) {
|
||||||
for ( ; try_port ; try_port++ ) {
|
while ( try_port ) {
|
||||||
|
try_port++;
|
||||||
if ( try_port < 1024 )
|
if ( try_port < 1024 )
|
||||||
continue;
|
continue;
|
||||||
if ( tcp_bind ( tcp, htons ( try_port ) ) == 0 )
|
if ( tcp_bind ( tcp, htons ( try_port ) ) == 0 )
|
||||||
|
|
Reference in New Issue