Browse Source

[udp] Avoid reusing auto-allocated ports after connection close.

This duplicates a fix made to tcp.c in commit
d5735c631c.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
21e9e801e2
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      src/net/udp.c

+ 3
- 2
src/net/udp.c View File

55
  */
55
  */
56
 static int udp_bind ( struct udp_connection *udp ) {
56
 static int udp_bind ( struct udp_connection *udp ) {
57
 	struct udp_connection *existing;
57
 	struct udp_connection *existing;
58
-	static uint16_t try_port = 1024;
58
+	static uint16_t try_port = 1023;
59
 
59
 
60
 	/* If no port specified, find the first available port */
60
 	/* If no port specified, find the first available port */
61
 	if ( ! udp->local.st_port ) {
61
 	if ( ! udp->local.st_port ) {
62
-		for ( ; try_port ; try_port++ ) {
62
+		while ( try_port ) {
63
+			try_port++;
63
 			if ( try_port < 1024 )
64
 			if ( try_port < 1024 )
64
 				continue;
65
 				continue;
65
 			udp->local.st_port = htons ( try_port );
66
 			udp->local.st_port = htons ( try_port );

Loading…
Cancel
Save