Przeglądaj źródła

Avoid reusing auto-allocated ports after connection close.

tags/v0.9.3
Michael Brown 17 lat temu
rodzic
commit
d5735c631c
1 zmienionych plików z 3 dodań i 2 usunięć
  1. 3
    2
      src/net/tcp.c

+ 3
- 2
src/net/tcp.c Wyświetl plik

@@ -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 )

Ładowanie…
Anuluj
Zapisz