Explorar el Código

Avoid reusing auto-allocated ports after connection close.

tags/v0.9.3
Michael Brown hace 17 años
padre
commit
d5735c631c
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3
    2
      src/net/tcp.c

+ 3
- 2
src/net/tcp.c Ver fichero

@@ -160,11 +160,12 @@ tcp_dump_flags ( struct tcp_connection *tcp, unsigned int flags ) {
160 160
  */
161 161
 static int tcp_bind ( struct tcp_connection *tcp, unsigned int port ) {
162 162
 	struct tcp_connection *existing;
163
-	static uint16_t try_port = 1024;
163
+	static uint16_t try_port = 1023;
164 164
 
165 165
 	/* If no port specified, find the first available port */
166 166
 	if ( ! port ) {
167
-		for ( ; try_port ; try_port++ ) {
167
+		while ( try_port ) {
168
+			try_port++;
168 169
 			if ( try_port < 1024 )
169 170
 				continue;
170 171
 			if ( tcp_bind ( tcp, htons ( try_port ) ) == 0 )

Loading…
Cancelar
Guardar